Source

ocaml-llists / examples / llistcons_orig.ml

Full commit
#load "camlp4o.cma"
#load "pa_llistcomp.cma"
#load "lazy_list.cmo"


open Lazy_list



let l = [% ]
in to_list l
(* - : 'a list = [] *)

let l = [% 1 ]
in to_list l
(* - : int list = [1] *)

let l = [% 1; 2; 3; 4; 5 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)


let l = [% 1 .. 5 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)

let l = [% 1 .. 5; 7; 9 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5; 7; 9] *)

let l = [% 1 .. 5; 7 .. 9 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5; 7; 8; 9] *)


let l = [% 2; 4 .. 9 ]
in to_list l
(* - : int list = [2; 4; 6; 8] *)

let l = [% 2; 3; 5 .. 9 ]
in to_list l
(* - : int list = [2; 3; 5; 7; 9] *)

let l = [% 3; 5 .. 9; 12 ]
in to_list l
(* - : int list = [3; 5; 7; 9; 12] *)


let l = [% 2; 3; 5 .. 9; 12 .. 14 ]
in to_list l
(* - : int list = [2; 3; 5; 7; 9; 12; 13; 14] *)

let l = [% 2; 3; 5 .. 9; 12; 14 .. 18 ]
in to_list l
(* - : int list = [2; 3; 5; 7; 9; 12; 14; 16; 18] *)


let l = take 5 [% 1; 3 .. ]
in to_list l
(* - : int list = [1; 3; 5; 7; 9] *)

let l = take 5 [% 2; 3; 5 .. ]
in to_list l
(* - : int list = [2; 3; 5; 7; 9] *)

let l = take 10 [% 2; 3; 5 .. 9; 11; 14 .. ]
in to_list l
(* - : int list = [2; 3; 5; 7; 9; 11; 14; 17; 20; 23] *)


let l = 1 %: [% ]
in to_list l
(* - : int list = [1] *)

let l = [% ] %: [% ]
in to_list l
(* - : 'a Lazy_list.t list = [lazy Nil] *)

let l = 1 %: [% 2; 3; 4; 5 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)

let l = 1 %: 2 %: [% 3; 4; 5 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)

let l = 1 %: 2 %: 3 %: 4 %: [% 5 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)

let l = 1 %: 2 %: [% 3 .. 5 ]
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)

let l = take 5 (1 %: 2 %: [% 3 .. ]) in
in to_list l
(* - : int list = [1; 2; 3; 4; 5] *)