[ create a new paste ] login | about

Link: http://codepad.org/KcqQN5tl    [ raw code | fork ]

OCaml, pasted on Jan 16:
let spots = seq { 1..10000000 }
let best = 3
let top = 99
let right = 111

(* Real: 00:00:02.924 *)
[ yield! [right;top]
  for spot in spots do 
    if spot <> best then 
      let rect = 1
      yield rect ] 

(* 00:00:05.408 *)
spots
|> Seq.filter (fun spot -> spot <> best)
|> Seq.map (fun spot -> let rect = 1 in rect)
|> Seq.append [right; top]
|> List.ofSeq


(*Real: 00:00:03.402*)
seq { 
  yield! [right;top]
  for spot in spots do 
    if spot <> best then 
      let rect = 1
      yield rect }
      |> List.ofSeq


Create a new paste based on this one


Comments: