Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| // NV_DX_interop : https://www.khronos.org/registry/OpenGL/extensions/NV/WGL_NV_DX_interop.txt | |
| // NV_DX_interop2 : https://www.khronos.org/registry/OpenGL/extensions/NV/WGL_NV_DX_interop2.txt | |
| // mmonzeiko's : https://gist.github.com/mmozeiko/c99f9891ce723234854f0919bfd88eae | |
| #include <Windows.h> | |
| #include <d3d11.h> | |
| #include <GL/GL.h> | |
| #include <GL/glext.h> | |
| #include <GL/wglext.h> |
| // | |
| // Code from "Numerical Recipe in C (2nd edition)" by Press et al. | |
| // Chapter 20.2 pg.896 | |
| // | |
| #include <cstdint> | |
| #include <iostream> | |
| // Return the Gray code of n | |
| uint64_t gray(uint64_t n) |
| /* | |
| * Copyright (c), Recep Aslantas. All rights reserved. | |
| */ | |
| #import <Cocoa/Cocoa.h> | |
| @protocol GLViewDelegate; | |
| @interface GLView : NSView { | |
| NSOpenGLContext * m_openGLContext; |
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| object sfti extends App { | |
| // 1. | |
| object Conversions { | |
| def inchesToCentimeters(in: Double) = 2.54*in | |
| def gallonsToLiters(gal: Double) = 3.78541 * gal | |
| def milesToKilometers(mi: Double) = 1.60934 * mi | |
| } | |
| // 2. |
| object sfti extends App { | |
| // 1. Improve the Counter class in Section 5.1, "Simple Classes and Parameterless | |
| // Methods," on page 51 so that it doesn't turn negative at Int.MaxValue. | |
| class Counter { | |
| private var value = 0 | |
| def increment() { | |
| if (Int.MaxValue > value) | |
| value += 1 | |
| } | |
| def current() = value |
| import util.Random | |
| import java.awt.datatransfer._ | |
| import scala.collection.mutable._ | |
| import java.util.TimeZone._ | |
| import java.awt.datatransfer._ | |
| object sfti extends App { | |
| // 1. Write a code snippet that sets a to an array of n random integers between 0 | |
| // (inclusive) and n (exclusive). | |
| val n = 10 |
| object sfti extends App { | |
| // 1. Set up a map of prices for a number of gizmos that you covet. Then produce | |
| // a second map with the same keys and the prices at a 10 percent discount. | |
| val gizmos = Map("iPod" -> 20000, "iPhone" -> 45000, "iPad" -> 30000, "iMac" -> 85000) | |
| val discounted = for ((name, price) <- gizmos) yield (name, 0.9*price) | |
| println(s"ex1 : $discounted") | |
| // 2. Write a program that reads words from a file. Use a mutable map to count | |
| // how often each word appears. To read the words, simply use a java.util.Scanner: | |
| // val in = new java.util.Scanner(java.io.File("myfile.txt")) |