Changeset 27158 in project


Ignore:
Timestamp:
08/02/12 13:50:25 (9 years ago)
Author:
juergen
Message:

documentation of lazy-lists updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/lazy-lists

    r27152 r27158  
    5555their documentation included, namely the equally named procedure
    5656
    57 === lazy-lists
    58 
    59 <enscript highlight=scheme>
    60 (lazy-lists)
    61 (lazy-list 'List)
    62 </enscript>
    63 
    64 The first call returns all available routines, the second documentation
    65 and contract of the symbol List
    66 
    67 
    68 === make-lazy
    69 
    70 <enscript highlight=scheme>
    71 (make-lazy len thunk)
    72 (domain (or (not len) (and (integer? len) (not (negative? len)))) (procedure? thunk) thunk returns either '(), a List or (cons val List))
     57==== lazy-lists
     58
     59<procedure>(lazy-lists [sym])</procedure>
     60
     61returns all available routines of the module when called without an
     62argument, but when called with one of these routines as a symbol,
     63returns its contract and documentation string.
     64
     65==== make-lazy
     66
     67<procedure>(make-lazy len thunk)</procedure>
     68
     69<enscript highlight=scheme>
     70(domain (or (not len) (and (integer? len) (not (negative? len))))
     71(procedure? thunk) "thunk returns either '(), a List or (cons val List)")
    7372(range (%List? result) (= (%Length result) len))
    7473</enscript>
     
    7675lazy constructor
    7776
    78 === Lazy
    79 
    80 <syntax>
    81 (Lazy len xpr . xprs)
    82 </syntax>
     77==== Lazy
     78
     79<syntax>(Lazy len xpr . xprs)</syntax>
    8380
    8481wrapper to make-lazy constructor
    8582
    86 
    87 === List?
    88 
    89 <enscript highlight=scheme>
    90 (List? xpr)
     83==== Nil
     84
     85empty lazy list
     86
     87==== List?
     88
     89<procedure>(List? xpr)</procedure>
     90
     91<enscript highlight=scheme>
    9192(range (boolean? result))
    9293</enscript>
     
    9495lazy version of list?
    9596
    96 === Length
    97 
    98 <enscript highlight=scheme>
    99 (Length seq)
     97==== Length
     98
     99<procedure>(Length seq)</procedure>
     100
     101<enscript highlight=scheme>
    100102(domain (%List? seq))
    101103(range (or (not result) (and (integer? result) (not (negative? result)))))
     
    104106lazy version of length
    105107
    106 === Cons
    107 
    108 <enscript highlight=scheme>
    109 (Cons var seq)
     108==== Cons
     109
     110<procedure>(Cons var seq)</procedure>
     111
     112<enscript highlight=scheme>
    110113(domain (%List? seq))
    111114(range (%List? result) (or (not (%Length seq)) (= (%Length result) (+ (%Length seq) 1))))
     
    114117lazy version of cons
    115118
    116 === Rest
    117 
    118 <enscript highlight=scheme>
    119 (Rest seq)
     119==== Rest
     120
     121<procedure>(Rest seq)</procedure>
     122
     123<enscript highlight=scheme>
    120124(domain (%List? seq) (not (%Null? seq)))
    121125(range (%List? result) (or (not (%Length seq)) (= (%Length result) (- (%Length seq) 1))))
     
    124128lazy version of cdr
    125129
    126 === Cdr
    127 
    128 <enscript highlight=scheme>
    129 (Cdr seq)
     130==== Cdr
     131
     132<procedure>(Cdr seq)</procedure>
     133
     134<enscript highlight=scheme>
    130135(domain (%List? seq) (not (%Null? seq)))
    131136(range (%List? result) (or (not (%Length seq)) (= (%Length result) (- (%Length seq) 1))))
     
    134139lazy version of cdr
    135140
    136 === First
    137 
    138 <enscript highlight=scheme>
    139 (First seq)
     141==== First
     142
     143<procedure>(First seq)</procedure>
     144
     145<enscript highlight=scheme>
    140146(domain (%List? seq) (not (%Null? seq)))
    141147</enscript>
     
    143149lazy version of car
    144150
    145 === Car
    146 
    147 <enscript highlight=scheme>
    148 (Car seq)
     151==== Car
     152
     153<procedure>(Car seq)</procedure>
     154
     155<enscript highlight=scheme>
    149156(domain (%List? seq) (not (%Null? seq)))
    150157</enscript>
     
    152159lazy version of car
    153160
    154 === Ref
    155 
    156 <enscript highlight=scheme>
    157 (Ref n seq)
     161==== Ref
     162
     163<procedure>(Ref n seq)</procedure>
     164
     165<enscript highlight=scheme>
    158166(domain (%List? seq) (integer? n) (or (not (%Length seq)) (< -1 n (%Length seq))))
    159167</enscript>
     
    161169lazy version of list-ref with changed argument order
    162170
    163 === Null?
    164 
    165 <enscript highlight=scheme>
    166 (Null? seq)
     171==== Null?
     172
     173<procedure>(Null? seq)</procedure>
     174
     175<enscript highlight=scheme>
    167176(domain (%List? seq))
    168177(range (boolean? result))
     
    171180lazy version of null?
    172181
    173 === Zip
    174 
    175 <enscript highlight=scheme>
    176 (Zip seq1 seq2)
     182==== Zip
     183
     184<procedure>(Zip seq1 seq2)</procedure>
     185
     186<enscript highlight=scheme>
    177187(domain (%List? seq1) (%List? seq2))
    178188(range (%List? result) (if (and (%Length seq1) (%Length seq2)) (= (%Length result) (+ (%Length seq1) (%Length seq2))) (not (%Length result))))
     
    181191interleave two lazy lists
    182192
    183 === Some?
    184 
    185 <enscript highlight=scheme>
    186 (Some? ok? seq)
     193==== Some?
     194
     195<procedure>(Some? ok? seq)</procedure>
     196
     197<enscript highlight=scheme>
    187198(domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)")
    188199</enscript>
     
    190201does some item of seq fulfill ok?
    191202
    192 === Every?
    193 
    194 <enscript highlight=scheme>
    195 (Every? ok? seq)
     203==== Every?
     204
     205<procedure>(Every? ok? seq)</procedure>
     206
     207<enscript highlight=scheme>
    196208(domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)")
    197209</enscript>
     
    199211does every item of seq fulfill ok?
    200212
    201 === Fold-right*
    202 
    203 <enscript highlight=scheme>
    204 (Fold-right* op base . seqs)
     213==== Fold-right*
     214
     215<procedure>(Fold-right* op base . seqs)</procedure>
     216
     217<enscript highlight=scheme>
    205218(domain (procedure? op) "(op b . ss)" ((list-of? %List?) seqs) (or (null? seqs) (all (lambda (x) (eqv? (%Length x) (%Length (car seqs)))) (cdr seqs))))
    206219(range (%List? result) (if (null? seqs) (not (%Length result)) (eqv? (%Length result) (%Length (car seqs)))))
     
    209222create a lazy list of right folds changing order or List items
    210223
    211 === Fold-left*
    212 
    213 <enscript highlight=scheme>
    214 (Fold-left* op base . seqs)
     224==== Fold-left*
     225
     226<procedure>(Fold-left* op base . seqs)</procedure>
     227
     228<enscript highlight=scheme>
    215229(domain (procedure? op) "(op b . ss)" ((list-of? %List?) seqs) (or (null? seqs) (all (lambda (x) (eqv? (%Length x) (%Length (car seqs)))) (cdr seqs))))
    216230(range (%List? result) (if (null? seqs) (not (%Length result)) (eqv? (%Length result) (%Length (car seqs)))))
     
    219233create a lazy list of left folds
    220234
    221 === Fold-right
    222 
    223 <enscript highlight=scheme>
    224 (Fold-right op base seq . seqs)
     235==== Fold-right
     236
     237<procedure>(Fold-right op base seq . seqs)</procedure>
     238
     239<enscript highlight=scheme>
    225240(domain (procedure? op) "(op b s . ss)" (%List? seq) ((list-of? %List?) seqs) (%Length seq) (all (lambda (x) (= (%Length x) (%Length seq))) seqs))
    226241</enscript>
     
    228243lazy version of fold-right
    229244
    230 === Fold-left
    231 
    232 <enscript highlight=scheme>
    233 (Fold-left op base seq . seqs)
     245==== Fold-left
     246
     247<procedure>(Fold-left op base seq . seqs)</procedure>
     248
     249<enscript highlight=scheme>
    234250(domain (procedure? op) "(op b s . ss)" (%List? seq) ((list-of? %List?) seqs) (%Length seq) (all (lambda (x) (= (%Length x) (%Length seq))) seqs))
    235251</enscript>
     
    237253lazy version of fold-left
    238254
    239 === Sieve
    240 
    241 <enscript highlight=scheme>
    242 (Sieve =? seq)
     255==== Sieve
     256
     257<procedure>(Sieve =? seq)</procedure>
     258
     259<enscript highlight=scheme>
    243260(domain (%List? seq) (procedure? =?) "(=? a b)")
    244 (range (%List? result) not two items =? (if (%Length seq) (<= (%Length result) (%Length seq)) (not (%Length result))))
     261(range (%List? result) "not two items =?" (if (%Length seq) (<= (%Length result) (%Length seq)) (not (%Length result))))
    245262</enscript>
    246263
    247264sieve of Erathostenes with respect to =?
    248265
    249 === Split-with
    250 
    251 <enscript highlight=scheme>
    252 (Split-with ok? seq)
     266==== Split-with
     267
     268<procedure>(Split-with ok? seq)</procedure>
     269
     270<enscript highlight=scheme>
    253271(domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)")
    254272(range (with-results (head index tail) (%List? head) (%List? tail) (integer? index) (not (negative? index)) (<= (%Length head) (%Length seq)) (<= (%Length tail) (%Length seq))))
     
    257275split a lazy list at first index fulfilling ok?
    258276
    259 === Split-at
    260 
    261 <enscript highlight=scheme>
    262 (Split-at n seq)
     277==== Split-at
     278
     279<procedure>(Split-at n seq)</procedure>
     280
     281<enscript highlight=scheme>
    263282(domain (%List? seq) (integer? n) (not (negative? n)))
    264283(range (with-results (head tail) (%List? head) (%Length head) (<= (%Length head) n) (%List? tail) (if (%Length seq) (<= (%Length tail) (%Length seq)) (not (%Length tail)))))
     
    267286split a List at fixed position
    268287
    269 === List->vector
    270 
    271 <enscript highlight=scheme>
    272 (List->vector seq)
     288==== List->vector
     289
     290<procedure>(List->vector seq)</procedure>
     291
     292<enscript highlight=scheme>
    273293(domain (%List? seq) (%Length seq))
    274294(range (vector? result) (eqv? (vector-length result) (%Length seq)))
     
    277297transform a finite lazy list into a vector
    278298
    279 === vector->List
    280 
    281 <enscript highlight=scheme>
    282 (vector->List vec)
     299==== vector->List
     300
     301<procedure>(vector->List vec)</procedure>
     302
     303<enscript highlight=scheme>
    283304(domain (vector? vec))
    284305(range (%List? result) (eqv? (%Length result) (vector-length vec)))
     
    287308transform a vector into a lazy list
    288309
    289 === Sort
    290 
    291 <enscript highlight=scheme>
    292 (Sort <? seq)
     310==== Sort
     311
     312<procedure>(Sort <? seq)</procedure>
     313
     314<enscript highlight=scheme>
    293315(domain (procedure? <?) "(<? a b)" (%List? seq) (%Length seq))
    294316(range (%List? result) "<? sorted" (eqv? (%Length result) (%Length seq)))
     
    297319sort a finite lazy list with respect to <?
    298320
    299 === Merge
    300 
    301 <enscript highlight=scheme>
    302 (Merge <? seq1 seq2)
     321==== Merge
     322
     323<procedure>(Merge <? seq1 seq2)</procedure>
     324
     325<enscript highlight=scheme>
    303326(domain (procedure? <?) "(<? a b)" (%List? seq1) (%Length seq1) <? sorted (%List? seq2) (%Length seq2) <? sorted)
    304327(range (%List? result) "<? sorted" (= (%Length result) (+ (%Length seq1) (%Length seq2))))
     
    307330merge two sorted lazy lists with respect to <?
    308331
    309 === Cycle
    310 
    311 <enscript highlight=scheme>
    312 (Cycle seq)
     332==== Cycle
     333
     334<procedure>(Cycle seq)</procedure>
     335
     336<enscript highlight=scheme>
    313337(domain (%List? seq) (%Length seq))
    314338(range (%List? result) (not (%Length result)))
     
    317341create infinite List by cycling finite List seq
    318342
    319 === Reverse*
    320 
    321 <enscript highlight=scheme>
    322 (Reverse* seq)
     343==== Reverse*
     344
     345<procedure>(Reverse* seq)</procedure>
     346
     347<enscript highlight=scheme>
    323348(domain (%List? seq))
    324349(range (%List? result) (eqv? (%Length result) (%Length seq)))
     
    327352List of successive reversed subLists
    328353
    329 === Reverse
    330 
    331 <enscript highlight=scheme>
    332 (Reverse seq)
     354==== Reverse
     355
     356<procedure>(Reverse seq)</procedure>
     357
     358<enscript highlight=scheme>
    333359(domain (%List? seq) (%Length seq))
    334360(range (%List? result) (%Length result) (= (%Length result) (%Length seq)))
     
    337363lazy version of reverse
    338364
    339 === Append
    340 
    341 <enscript highlight=scheme>
    342 (Append . seqs)
     365==== Append
     366
     367<procedure>(Append . seqs)</procedure>
     368
     369<enscript highlight=scheme>
    343370(domain ((list-of? %List?) seqs) (let ((lst (memv #f (map %Length seqs)))) (or (not lst) (<= (length lst) 1))))
    344371(range (%List? result) (or (not (%Length result)) (= (%Length result) (apply + (map %Length seqs)))))
     
    347374lazy version of append
    348375
    349 === Iterate
    350 
    351 <enscript highlight=scheme>
    352 (Iterate proc x)
     376==== Iterate
     377
     378<procedure>(Iterate proc x)</procedure>
     379
     380<enscript highlight=scheme>
    353381(domain (procedure? proc) "(proc x)")
    354382(range (%List? result) (not (%Length result)))
     
    357385create infinite List by applying proc succesively to x
    358386
    359 === Repeatedly
    360 
    361 <enscript highlight=scheme>
    362 (Repeatedly thunk)
     387==== Repeatedly
     388
     389<procedure>(Repeatedly thunk)</procedure>
     390
     391<enscript highlight=scheme>
    363392(domain (procedure? thunk))
    364393(range (%List? result) (not (%Length result)))
     
    367396create infinite List of return values of thunk
    368397
    369 === Repeat
    370 
    371 <enscript highlight=scheme>
    372 (Repeat x)
     398==== Repeat
     399
     400<procedure>(Repeat x)</procedure>
     401
     402<enscript highlight=scheme>
    373403(range (%List? result) (not (%Length result)))
    374404</enscript>
     
    376406create infinite List of x
    377407
    378 === input->List
    379 
    380 <enscript highlight=scheme>
    381 (input->List port read-proc)
     408==== input->List
     409
     410<procedure>(input->List port read-proc)</procedure>
     411
     412<enscript highlight=scheme>
    382413(domain (input-port? port) (procedure? read-proc))
    383414(range (%List? result) (%Length result))
     
    386417transform input port into List with read-proc
    387418
    388 === For-each
    389 
    390 <enscript highlight=scheme>
    391 (For-each proc seq . seqs)
     419==== For-each
     420
     421<procedure>(For-each proc seq . seqs)</procedure>
     422
     423<enscript highlight=scheme>
    392424(domain (%List? seq) ((list-of? %List?) seqs) (procedure? proc) "(proc arg . args)" (all (lambda (x) (eqv? (%Length x) (%Length seq))) seqs))
    393425</enscript>
     
    395427lazy version of for-each
    396428
    397 === Filter
    398 
    399 <enscript highlight=scheme>
    400 (Filter ok? seq)
     429==== Filter
     430
     431<procedure>(Filter ok? seq)</procedure>
     432
     433<enscript highlight=scheme>
    401434(domain (%List? seq) (procedure? ok?) "(ok? x)")
    402435(range (%List? result) (or (not (%Length seq)) (<= (%Length result) (%Length seq))))
     
    405438lazy version of filter
    406439
    407 === Map
    408 
    409 <enscript highlight=scheme>
    410 (Map proc seq . seqs)
     440==== Map
     441
     442<procedure>(Map proc seq . seqs)</procedure>
     443
     444<enscript highlight=scheme>
    411445(domain (%List? seq) ((list-of? %List?) seqs) (procedure? proc) "(proc arg . args)" (all (lambda (x) (eqv? (%Length x) (%Length seq))) seqs))
    412446(range (%List? result) (eqv? (%Length result) (%Length seq)))
     
    415449lazy version of map
    416450
    417 === Assoc
    418 
    419 <enscript highlight=scheme>
    420 (Assoc key aseq)
    421 (domain (%List? aseq) List of pairs (%Length aseq))
     451==== Assoc
     452
     453<procedure>(Assoc key aseq)</procedure>
     454
     455<enscript highlight=scheme>
     456(domain (%List? aseq) "List of pairs" (%Length aseq))
    422457(range (or (not result) (pair? result)))
    423458</enscript>
     
    425460lazy version of assoq
    426461
    427 === Assv
    428 
    429 <enscript highlight=scheme>
    430 (Assv key aseq)
    431 (domain (%List? aseq) List of pairs (%Length aseq))
     462==== Assv
     463
     464<procedure>(Assv key aseq)</procedure>
     465
     466<enscript highlight=scheme>
     467(domain (%List? aseq) "List of pairs" (%Length aseq))
    432468(range (or (not result) (pair? result)))
    433469</enscript>
     
    435471lazy version of assv
    436472
    437 === Assq
    438 
    439 <enscript highlight=scheme>
    440 (Assq key aseq)
    441 (domain (%List? aseq) List of pairs (%Length aseq))
     473==== Assq
     474
     475<procedure>(Assq key aseq)</procedure>
     476
     477<enscript highlight=scheme>
     478(domain (%List? aseq) "List of pairs" (%Length aseq))
    442479(range (or (not result) (pair? result)))
    443480</enscript>
     
    445482lazy version of assq
    446483
    447 === Assp
    448 
    449 <enscript highlight=scheme>
    450 (Assp ok? aseq)
    451 (domain (%List? aseq) List of pairs (%Length aseq) (procedure? ok?) "(ok? x)")
     484==== Assp
     485
     486<procedure>(Assp ok? aseq)</procedure>
     487
     488<enscript highlight=scheme>
     489(domain (%List? aseq) "List of pairs" (%Length aseq) (procedure? ok?) "(ok? x)")
    452490(range (or (not result) (pair? result)))
    453491</enscript>
     
    455493return #f or first pair, whose Car fulfills ok?
    456494
    457 === Equal?
    458 
    459 <enscript highlight=scheme>
    460 (Equal? seq1 seq2)
     495==== Equal?
     496
     497<procedure>(Equal? seq1 seq2)</procedure>
     498
     499<enscript highlight=scheme>
    461500(domain (%List? seq1) (%List? seq2))
    462501(range (boolean? result))
     
    465504lazy version of equal?
    466505
    467 === Eqv?
    468 
    469 <enscript highlight=scheme>
    470 (Eqv? seq1 seq2)
     506==== Eqv?
     507
     508<procedure>(Eqv? seq1 seq2)</procedure>
     509
     510<enscript highlight=scheme>
    471511(domain (%List? seq1) (%List? seq2))
    472512(range (boolean? result))
     
    475515lazy version of eqv?
    476516
    477 === Eq?
    478 
    479 <enscript highlight=scheme>
    480 (Eq? seq1 seq2)
     517==== Eq?
     518
     519<procedure>(Eq? seq1 seq2)</procedure>
     520
     521<enscript highlight=scheme>
    481522(domain (%List? seq1) (%List? seq2))
    482523(range (boolean? result))
     
    485526lazy version of eq?
    486527
    487 === Equ?
    488 
    489 <enscript highlight=scheme>
    490 (Equ? =? seq1 seq2)
     528==== Equ?
     529
     530<procedure>(Equ? =? seq1 seq2)</procedure>
     531
     532<enscript highlight=scheme>
    491533(domain (%List? seq1) (%List? seq2) (procedure? =?) "(=? x y)")
    492534(range (boolean? result))
     
    495537compare two Lists with predicate =?
    496538
    497 === Member
    498 
    499 <enscript highlight=scheme>
    500 (Member var seq)
     539==== Member
     540
     541<procedure>(Member var seq)</procedure>
     542
     543<enscript highlight=scheme>
    501544(domain (%List? seq) (%Length seq))
    502545(range (%List? result) (<= (%Length result) (%Length seq)))
     
    505548lazy version of member
    506549
    507 === Memv
    508 
    509 <enscript highlight=scheme>
    510 (Memv var seq)
     550==== Memv
     551
     552<procedure>(Memv var seq)</procedure>
     553
     554<enscript highlight=scheme>
    511555(domain (%List? seq) (%Length seq))
    512556(range (%List? result) (<= (%Length result) (%Length seq)))
     
    515559lazy version of memv
    516560
    517 === Memq
    518 
    519 <enscript highlight=scheme>
    520 (Memq var seq)
     561==== Memq
     562
     563<procedure>(Memq var seq)</procedure>
     564
     565<enscript highlight=scheme>
    521566(domain (%List? seq) (%Length seq))
    522567(range (%List? result) (<= (%Length result) (%Length seq)))
     
    525570lazy version of memq
    526571
    527 === Memp
    528 
    529 <enscript highlight=scheme>
    530 (Memp ok? seq)
     572==== Memp
     573
     574<procedure>(Memp ok? seq)</procedure>
     575
     576<enscript highlight=scheme>
    531577(domain (%List? seq) (%Length seq) (procedure? ok?) (ok? x))
    532578(range (%List? result) (<= (%Length result) (%Length seq)))
     
    535581Tail of items not fulfilling ok?
    536582
    537 === Index
    538 
    539 <enscript highlight=scheme>
    540 (Index ok? seq)
     583==== Index
     584
     585<procedure>(Index ok? seq)</procedure>
     586
     587<enscript highlight=scheme>
    541588(domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)")
    542589(range (integer? result) (not (negative? result)))
     
    545592return index of first item fulfilling ok?
    546593
    547 === Drop-upto
    548 
    549 <enscript highlight=scheme>
    550 (Drop-upto ok? seq)
     594==== Drop-upto
     595
     596<procedure>(Drop-upto ok? seq)</procedure>
     597
     598<enscript highlight=scheme>
    551599(domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)")
    552600(range (%List? result) (<= (%Length result) (%Length seq)))
     
    555603Tail of items not fulfilling ok?
    556604
    557 === Take-upto
    558 
    559 <enscript highlight=scheme>
    560 (Take-upto ok? seq)
     605==== Take-upto
     606
     607<procedure>(Take-upto ok? seq)</procedure>
     608
     609<enscript highlight=scheme>
    561610(domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)")
    562611(range (%List? result) (<= (%Length result) (%Length seq)))
     
    565614List of head items fulfilling ok?
    566615
    567 === Drop
    568 
    569 <enscript highlight=scheme>
    570 (Drop n seq)
     616==== Drop
     617
     618<procedure>(Drop n seq)</procedure>
     619
     620<enscript highlight=scheme>
    571621(domain (%List? seq) (integer? n) (not (negative? n)))
    572622(range (%List? result) (if (%Length seq) (= (%Length result) (max 0 (- (%Length seq) n))) (not (%Length result))))
     
    575625lazy version of list-tail with changed argument order
    576626
    577 === Take
    578 
    579 <enscript highlight=scheme>
    580 (Take n seq)
     627==== Take
     628
     629<procedure>(Take n seq)</procedure>
     630
     631<enscript highlight=scheme>
    581632(domain (%List? seq) (integer? n) (not (negative? n)))
    582633(range (%List? result) (%Length result) (if (%Length seq) (= (%Length result) (min n (%Length seq))) (= (%Length result) n)))
     
    585636List of first n items of seq
    586637
    587 === List
    588 
    589 <enscript highlight=scheme>
    590 (List . args)
     638==== List
     639
     640<procedure>(List . args)</procedure>
     641
     642<enscript highlight=scheme>
    591643(range (%List? result) (eqv? (%Length result) (length args)))
    592644</enscript>
     
    594646lazy version of list
    595647
    596 === list->List
    597 
    598 <enscript highlight=scheme>
    599 (list->List lst)
     648==== list->List
     649
     650<procedure>(list->List lst)</procedure>
     651
     652<enscript highlight=scheme>
    600653(domain (list? lst))
    601654(range (%List? result) (eqv? (%Length result) (length lst)))
     
    604657transform ordinary list into finite lazy list
    605658
    606 === List->list
    607 
    608 <enscript highlight=scheme>
    609 (List->list seq)
     659==== List->list
     660
     661<procedure>(List->list seq)</procedure>
     662
     663<enscript highlight=scheme>
    610664(domain (%List? seq) (%Length seq))
    611665(range (list? result))
     
    614668transform finite lazy into ordinary list
    615669
    616 === Realized?
    617 
    618 <enscript highlight=scheme>
    619 (Realized? seq)
     670==== Realized?
     671
     672<procedure>(Realized? seq)</procedure>
     673
     674<enscript highlight=scheme>
    620675(domain (%List? seq))
    621676(range (boolean? result))
     
    624679Is seq realized?
    625680
    626 === Primes
    627 
    628 <enscript highlight=scheme>
    629 (Primes)
     681==== Primes
     682
     683<procedure>(Primes)</procedure>
     684
     685<enscript highlight=scheme>
    630686(range (%List? result) (not (%Length result)))
    631687</enscript>
     
    633689lazy list of non prime numbers
    634690
    635 === Cardinals
    636 
    637 <enscript highlight=scheme>
    638 (Cardinals)
     691==== Cardinals
     692
     693<procedure>(Cardinals)</procedure>
     694
     695<enscript highlight=scheme>
    639696(range (%List? result) (not (%Length result)))
    640697</enscript>
     
    642699lazy list of non negative integers
    643700
    644 === Interval
    645 
    646 <enscript highlight=scheme>
    647 (Interval from upto)
     701==== Interval
     702
     703<procedure>(Interval from upto)</procedure>
     704
     705<enscript highlight=scheme>
    648706(domain (integer? from) (integer? upto))
    649707(range (%List result) (= (%Length result) (abs (- upto from))))
     
    655713
    656714<enscript highlight=scheme>
    657 
    658715(use lazy-lists contracts)
     716</enscript>
    659717
    660718== Examples
     
    860918== Updated
    861919
     920Aug 2, 2012
     921
    862922== License
    863923
Note: See TracChangeset for help on using the changeset viewer.