(* This may look like SML, but the semantics must be
 * call-by-name or lazy. Strict evaluation won't work.
 *)
let val rec filter = fn p => fn xs0 =>
		       case xs0
			 of [] => []
			  | (x::xs) =>
			      if (p x) then x :: (filter p xs)
			      else filter p xs
    val rec take = fn n0 => fn xs0 =>
		     case n0
		       of 0 => []
			| n =>
			    case xs0
			      of (x::xs) => x :: (take (n - 1) xs)
			       | [] => []
    val rec from = fn n => n :: (from (n + 1))
    val not_div = fn x => fn y => (y mod x) <> 0
    val rec sieve = fn xs0 =>
		      case xs0
			of (x::xs) => x :: (sieve (filter (not_div x) xs))
    val primes = sieve (from 2)
    val N = 15 (* parameter *)
in
  take N primes
end
