Source

ocaml-llists / examples / llistcons_rev.ml

#load "camlp4r.cma" ;;
#load "pa_llistcomp.cma" ;
#load "lazy_list.cmo" ;


open Lazy_list ;



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

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

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


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

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

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


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

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

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


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

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


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

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

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


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

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

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

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

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

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

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

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

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