home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / examples / lexyacc / cl / takefrom.cl < prev   
Encoding:
Text File  |  1997-08-18  |  340 b   |  13 lines  |  [TEXT/R*ch]

  1. (* Stolen and edited from Klaus Elmquist Nielsen, Copyright (c) 1993 *)
  2.  
  3. letrec
  4.    take = \n.\xs.case xs of
  5.                 <1>      -> pack {1} ;
  6.                 <2> x xr -> if n=0 then pack {1}
  7.                             else pack {2, x, take (n-1) xr}
  8.                 end;
  9.  
  10.    from = \n. pack{2, n, from (n+1)}
  11. in take 1000 (from 117)
  12.  
  13.