Skip to content

Instantly share code, notes, and snippets.

View sshine's full-sized avatar
🦀

Simon Shine sshine

🦀
View GitHub Profile
@sshine
sshine / MultiServer.java
Created November 15, 2011 17:25
Java: A modification of KKMultiServer
package multiserver;
import java.net.*;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class MultiServer {
protected ServerSocket serverSocket = null;
protected boolean listening = true;
@sshine
sshine / gist:1329208
Created October 31, 2011 22:17
Standard ML functor example
signature FOO =
sig
type 'a foo
val f : 'a -> 'a foo
end
signature BAR =
sig
structure Foo : FOO
val p : 'a -> bool
@sshine
sshine / listekomb.sml
Created October 25, 2011 14:25
Standard ML functors and list combinators
(* Først defineres en signatur for lister. Den indeholder nogle
* af de mest elementære operationer, man kan lave på lister. *)
signature LISTE =
sig
type 'a liste
val null : 'a liste -> bool
val empty : 'a liste
val cons : 'a * 'a liste -> 'a liste
val hd : 'a liste -> 'a
val tl : 'a liste -> 'a liste
@sshine
sshine / gist:1307449
Created October 23, 2011 15:02
Standard ML: Imperative vs. functional
infixr 0 $
fun f $ x = f x
val concat = List.concat
fun good_cartesian_product (xs, ys) =
concat (map (fn y => map (fn x => (x,y)) xs) ys)
fun evil_cartesian_product (xs', ys') =
let
val result = ref []