Changeset 27158 in project
 Timestamp:
 08/02/12 13:50:25 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/lazylists
r27152 r27158 55 55 their documentation included, namely the equally named procedure 56 56 57 === lazylists 58 59 <enscript highlight=scheme> 60 (lazylists) 61 (lazylist '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 === makelazy 69 70 <enscript highlight=scheme> 71 (makelazy 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 ==== lazylists 58 59 <procedure>(lazylists [sym])</procedure> 60 61 returns all available routines of the module when called without an 62 argument, but when called with one of these routines as a symbol, 63 returns its contract and documentation string. 64 65 ==== makelazy 66 67 <procedure>(makelazy 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)") 73 72 (range (%List? result) (= (%Length result) len)) 74 73 </enscript> … … 76 75 lazy constructor 77 76 78 === Lazy 79 80 <syntax> 81 (Lazy len xpr . xprs) 82 </syntax> 77 ==== Lazy 78 79 <syntax>(Lazy len xpr . xprs)</syntax> 83 80 84 81 wrapper to makelazy constructor 85 82 86 87 === List? 88 89 <enscript highlight=scheme> 90 (List? xpr) 83 ==== Nil 84 85 empty lazy list 86 87 ==== List? 88 89 <procedure>(List? xpr)</procedure> 90 91 <enscript highlight=scheme> 91 92 (range (boolean? result)) 92 93 </enscript> … … 94 95 lazy version of list? 95 96 96 === Length 97 98 <enscript highlight=scheme> 99 (Length seq) 97 ==== Length 98 99 <procedure>(Length seq)</procedure> 100 101 <enscript highlight=scheme> 100 102 (domain (%List? seq)) 101 103 (range (or (not result) (and (integer? result) (not (negative? result))))) … … 104 106 lazy version of length 105 107 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> 110 113 (domain (%List? seq)) 111 114 (range (%List? result) (or (not (%Length seq)) (= (%Length result) (+ (%Length seq) 1)))) … … 114 117 lazy version of cons 115 118 116 === Rest 117 118 <enscript highlight=scheme> 119 (Rest seq) 119 ==== Rest 120 121 <procedure>(Rest seq)</procedure> 122 123 <enscript highlight=scheme> 120 124 (domain (%List? seq) (not (%Null? seq))) 121 125 (range (%List? result) (or (not (%Length seq)) (= (%Length result) ( (%Length seq) 1)))) … … 124 128 lazy version of cdr 125 129 126 === Cdr 127 128 <enscript highlight=scheme> 129 (Cdr seq) 130 ==== Cdr 131 132 <procedure>(Cdr seq)</procedure> 133 134 <enscript highlight=scheme> 130 135 (domain (%List? seq) (not (%Null? seq))) 131 136 (range (%List? result) (or (not (%Length seq)) (= (%Length result) ( (%Length seq) 1)))) … … 134 139 lazy version of cdr 135 140 136 === First 137 138 <enscript highlight=scheme> 139 (First seq) 141 ==== First 142 143 <procedure>(First seq)</procedure> 144 145 <enscript highlight=scheme> 140 146 (domain (%List? seq) (not (%Null? seq))) 141 147 </enscript> … … 143 149 lazy version of car 144 150 145 === Car 146 147 <enscript highlight=scheme> 148 (Car seq) 151 ==== Car 152 153 <procedure>(Car seq)</procedure> 154 155 <enscript highlight=scheme> 149 156 (domain (%List? seq) (not (%Null? seq))) 150 157 </enscript> … … 152 159 lazy version of car 153 160 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> 158 166 (domain (%List? seq) (integer? n) (or (not (%Length seq)) (< 1 n (%Length seq)))) 159 167 </enscript> … … 161 169 lazy version of listref with changed argument order 162 170 163 === Null? 164 165 <enscript highlight=scheme> 166 (Null? seq) 171 ==== Null? 172 173 <procedure>(Null? seq)</procedure> 174 175 <enscript highlight=scheme> 167 176 (domain (%List? seq)) 168 177 (range (boolean? result)) … … 171 180 lazy version of null? 172 181 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> 177 187 (domain (%List? seq1) (%List? seq2)) 178 188 (range (%List? result) (if (and (%Length seq1) (%Length seq2)) (= (%Length result) (+ (%Length seq1) (%Length seq2))) (not (%Length result)))) … … 181 191 interleave two lazy lists 182 192 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> 187 198 (domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)") 188 199 </enscript> … … 190 201 does some item of seq fulfill ok? 191 202 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> 196 208 (domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)") 197 209 </enscript> … … 199 211 does every item of seq fulfill ok? 200 212 201 === Foldright* 202 203 <enscript highlight=scheme> 204 (Foldright* op base . seqs) 213 ==== Foldright* 214 215 <procedure>(Foldright* op base . seqs)</procedure> 216 217 <enscript highlight=scheme> 205 218 (domain (procedure? op) "(op b . ss)" ((listof? %List?) seqs) (or (null? seqs) (all (lambda (x) (eqv? (%Length x) (%Length (car seqs)))) (cdr seqs)))) 206 219 (range (%List? result) (if (null? seqs) (not (%Length result)) (eqv? (%Length result) (%Length (car seqs))))) … … 209 222 create a lazy list of right folds changing order or List items 210 223 211 === Foldleft* 212 213 <enscript highlight=scheme> 214 (Foldleft* op base . seqs) 224 ==== Foldleft* 225 226 <procedure>(Foldleft* op base . seqs)</procedure> 227 228 <enscript highlight=scheme> 215 229 (domain (procedure? op) "(op b . ss)" ((listof? %List?) seqs) (or (null? seqs) (all (lambda (x) (eqv? (%Length x) (%Length (car seqs)))) (cdr seqs)))) 216 230 (range (%List? result) (if (null? seqs) (not (%Length result)) (eqv? (%Length result) (%Length (car seqs))))) … … 219 233 create a lazy list of left folds 220 234 221 === Foldright 222 223 <enscript highlight=scheme> 224 (Foldright op base seq . seqs) 235 ==== Foldright 236 237 <procedure>(Foldright op base seq . seqs)</procedure> 238 239 <enscript highlight=scheme> 225 240 (domain (procedure? op) "(op b s . ss)" (%List? seq) ((listof? %List?) seqs) (%Length seq) (all (lambda (x) (= (%Length x) (%Length seq))) seqs)) 226 241 </enscript> … … 228 243 lazy version of foldright 229 244 230 === Foldleft 231 232 <enscript highlight=scheme> 233 (Foldleft op base seq . seqs) 245 ==== Foldleft 246 247 <procedure>(Foldleft op base seq . seqs)</procedure> 248 249 <enscript highlight=scheme> 234 250 (domain (procedure? op) "(op b s . ss)" (%List? seq) ((listof? %List?) seqs) (%Length seq) (all (lambda (x) (= (%Length x) (%Length seq))) seqs)) 235 251 </enscript> … … 237 253 lazy version of foldleft 238 254 239 === Sieve 240 241 <enscript highlight=scheme> 242 (Sieve =? seq) 255 ==== Sieve 256 257 <procedure>(Sieve =? seq)</procedure> 258 259 <enscript highlight=scheme> 243 260 (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)))) 245 262 </enscript> 246 263 247 264 sieve of Erathostenes with respect to =? 248 265 249 === Splitwith 250 251 <enscript highlight=scheme> 252 (Splitwith ok? seq) 266 ==== Splitwith 267 268 <procedure>(Splitwith ok? seq)</procedure> 269 270 <enscript highlight=scheme> 253 271 (domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)") 254 272 (range (withresults (head index tail) (%List? head) (%List? tail) (integer? index) (not (negative? index)) (<= (%Length head) (%Length seq)) (<= (%Length tail) (%Length seq)))) … … 257 275 split a lazy list at first index fulfilling ok? 258 276 259 === Splitat 260 261 <enscript highlight=scheme> 262 (Splitat n seq) 277 ==== Splitat 278 279 <procedure>(Splitat n seq)</procedure> 280 281 <enscript highlight=scheme> 263 282 (domain (%List? seq) (integer? n) (not (negative? n))) 264 283 (range (withresults (head tail) (%List? head) (%Length head) (<= (%Length head) n) (%List? tail) (if (%Length seq) (<= (%Length tail) (%Length seq)) (not (%Length tail))))) … … 267 286 split a List at fixed position 268 287 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> 273 293 (domain (%List? seq) (%Length seq)) 274 294 (range (vector? result) (eqv? (vectorlength result) (%Length seq))) … … 277 297 transform a finite lazy list into a vector 278 298 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> 283 304 (domain (vector? vec)) 284 305 (range (%List? result) (eqv? (%Length result) (vectorlength vec))) … … 287 308 transform a vector into a lazy list 288 309 289 === Sort 290 291 <enscript highlight=scheme> 292 (Sort <? seq) 310 ==== Sort 311 312 <procedure>(Sort <? seq)</procedure> 313 314 <enscript highlight=scheme> 293 315 (domain (procedure? <?) "(<? a b)" (%List? seq) (%Length seq)) 294 316 (range (%List? result) "<? sorted" (eqv? (%Length result) (%Length seq))) … … 297 319 sort a finite lazy list with respect to <? 298 320 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> 303 326 (domain (procedure? <?) "(<? a b)" (%List? seq1) (%Length seq1) <? sorted (%List? seq2) (%Length seq2) <? sorted) 304 327 (range (%List? result) "<? sorted" (= (%Length result) (+ (%Length seq1) (%Length seq2)))) … … 307 330 merge two sorted lazy lists with respect to <? 308 331 309 === Cycle 310 311 <enscript highlight=scheme> 312 (Cycle seq) 332 ==== Cycle 333 334 <procedure>(Cycle seq)</procedure> 335 336 <enscript highlight=scheme> 313 337 (domain (%List? seq) (%Length seq)) 314 338 (range (%List? result) (not (%Length result))) … … 317 341 create infinite List by cycling finite List seq 318 342 319 === Reverse* 320 321 <enscript highlight=scheme> 322 (Reverse* seq) 343 ==== Reverse* 344 345 <procedure>(Reverse* seq)</procedure> 346 347 <enscript highlight=scheme> 323 348 (domain (%List? seq)) 324 349 (range (%List? result) (eqv? (%Length result) (%Length seq))) … … 327 352 List of successive reversed subLists 328 353 329 === Reverse 330 331 <enscript highlight=scheme> 332 (Reverse seq) 354 ==== Reverse 355 356 <procedure>(Reverse seq)</procedure> 357 358 <enscript highlight=scheme> 333 359 (domain (%List? seq) (%Length seq)) 334 360 (range (%List? result) (%Length result) (= (%Length result) (%Length seq))) … … 337 363 lazy version of reverse 338 364 339 === Append 340 341 <enscript highlight=scheme> 342 (Append . seqs) 365 ==== Append 366 367 <procedure>(Append . seqs)</procedure> 368 369 <enscript highlight=scheme> 343 370 (domain ((listof? %List?) seqs) (let ((lst (memv #f (map %Length seqs)))) (or (not lst) (<= (length lst) 1)))) 344 371 (range (%List? result) (or (not (%Length result)) (= (%Length result) (apply + (map %Length seqs))))) … … 347 374 lazy version of append 348 375 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> 353 381 (domain (procedure? proc) "(proc x)") 354 382 (range (%List? result) (not (%Length result))) … … 357 385 create infinite List by applying proc succesively to x 358 386 359 === Repeatedly 360 361 <enscript highlight=scheme> 362 (Repeatedly thunk) 387 ==== Repeatedly 388 389 <procedure>(Repeatedly thunk)</procedure> 390 391 <enscript highlight=scheme> 363 392 (domain (procedure? thunk)) 364 393 (range (%List? result) (not (%Length result))) … … 367 396 create infinite List of return values of thunk 368 397 369 === Repeat 370 371 <enscript highlight=scheme> 372 (Repeat x) 398 ==== Repeat 399 400 <procedure>(Repeat x)</procedure> 401 402 <enscript highlight=scheme> 373 403 (range (%List? result) (not (%Length result))) 374 404 </enscript> … … 376 406 create infinite List of x 377 407 378 === input>List 379 380 <enscript highlight=scheme> 381 (input>List port readproc) 408 ==== input>List 409 410 <procedure>(input>List port readproc)</procedure> 411 412 <enscript highlight=scheme> 382 413 (domain (inputport? port) (procedure? readproc)) 383 414 (range (%List? result) (%Length result)) … … 386 417 transform input port into List with readproc 387 418 388 === Foreach 389 390 <enscript highlight=scheme> 391 (Foreach proc seq . seqs) 419 ==== Foreach 420 421 <procedure>(Foreach proc seq . seqs)</procedure> 422 423 <enscript highlight=scheme> 392 424 (domain (%List? seq) ((listof? %List?) seqs) (procedure? proc) "(proc arg . args)" (all (lambda (x) (eqv? (%Length x) (%Length seq))) seqs)) 393 425 </enscript> … … 395 427 lazy version of foreach 396 428 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> 401 434 (domain (%List? seq) (procedure? ok?) "(ok? x)") 402 435 (range (%List? result) (or (not (%Length seq)) (<= (%Length result) (%Length seq)))) … … 405 438 lazy version of filter 406 439 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> 411 445 (domain (%List? seq) ((listof? %List?) seqs) (procedure? proc) "(proc arg . args)" (all (lambda (x) (eqv? (%Length x) (%Length seq))) seqs)) 412 446 (range (%List? result) (eqv? (%Length result) (%Length seq))) … … 415 449 lazy version of map 416 450 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)) 422 457 (range (or (not result) (pair? result))) 423 458 </enscript> … … 425 460 lazy version of assoq 426 461 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)) 432 468 (range (or (not result) (pair? result))) 433 469 </enscript> … … 435 471 lazy version of assv 436 472 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)) 442 479 (range (or (not result) (pair? result))) 443 480 </enscript> … … 445 482 lazy version of assq 446 483 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)") 452 490 (range (or (not result) (pair? result))) 453 491 </enscript> … … 455 493 return #f or first pair, whose Car fulfills ok? 456 494 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> 461 500 (domain (%List? seq1) (%List? seq2)) 462 501 (range (boolean? result)) … … 465 504 lazy version of equal? 466 505 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> 471 511 (domain (%List? seq1) (%List? seq2)) 472 512 (range (boolean? result)) … … 475 515 lazy version of eqv? 476 516 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> 481 522 (domain (%List? seq1) (%List? seq2)) 482 523 (range (boolean? result)) … … 485 526 lazy version of eq? 486 527 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> 491 533 (domain (%List? seq1) (%List? seq2) (procedure? =?) "(=? x y)") 492 534 (range (boolean? result)) … … 495 537 compare two Lists with predicate =? 496 538 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> 501 544 (domain (%List? seq) (%Length seq)) 502 545 (range (%List? result) (<= (%Length result) (%Length seq))) … … 505 548 lazy version of member 506 549 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> 511 555 (domain (%List? seq) (%Length seq)) 512 556 (range (%List? result) (<= (%Length result) (%Length seq))) … … 515 559 lazy version of memv 516 560 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> 521 566 (domain (%List? seq) (%Length seq)) 522 567 (range (%List? result) (<= (%Length result) (%Length seq))) … … 525 570 lazy version of memq 526 571 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> 531 577 (domain (%List? seq) (%Length seq) (procedure? ok?) (ok? x)) 532 578 (range (%List? result) (<= (%Length result) (%Length seq))) … … 535 581 Tail of items not fulfilling ok? 536 582 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> 541 588 (domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)") 542 589 (range (integer? result) (not (negative? result))) … … 545 592 return index of first item fulfilling ok? 546 593 547 === Dropupto 548 549 <enscript highlight=scheme> 550 (Dropupto ok? seq) 594 ==== Dropupto 595 596 <procedure>(Dropupto ok? seq)</procedure> 597 598 <enscript highlight=scheme> 551 599 (domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)") 552 600 (range (%List? result) (<= (%Length result) (%Length seq))) … … 555 603 Tail of items not fulfilling ok? 556 604 557 === Takeupto 558 559 <enscript highlight=scheme> 560 (Takeupto ok? seq) 605 ==== Takeupto 606 607 <procedure>(Takeupto ok? seq)</procedure> 608 609 <enscript highlight=scheme> 561 610 (domain (%List? seq) (%Length seq) (procedure? ok?) "(ok? x)") 562 611 (range (%List? result) (<= (%Length result) (%Length seq))) … … 565 614 List of head items fulfilling ok? 566 615 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> 571 621 (domain (%List? seq) (integer? n) (not (negative? n))) 572 622 (range (%List? result) (if (%Length seq) (= (%Length result) (max 0 ( (%Length seq) n))) (not (%Length result)))) … … 575 625 lazy version of listtail with changed argument order 576 626 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> 581 632 (domain (%List? seq) (integer? n) (not (negative? n))) 582 633 (range (%List? result) (%Length result) (if (%Length seq) (= (%Length result) (min n (%Length seq))) (= (%Length result) n))) … … 585 636 List of first n items of seq 586 637 587 === List 588 589 <enscript highlight=scheme> 590 (List . args) 638 ==== List 639 640 <procedure>(List . args)</procedure> 641 642 <enscript highlight=scheme> 591 643 (range (%List? result) (eqv? (%Length result) (length args))) 592 644 </enscript> … … 594 646 lazy version of list 595 647 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> 600 653 (domain (list? lst)) 601 654 (range (%List? result) (eqv? (%Length result) (length lst))) … … 604 657 transform ordinary list into finite lazy list 605 658 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> 610 664 (domain (%List? seq) (%Length seq)) 611 665 (range (list? result)) … … 614 668 transform finite lazy into ordinary list 615 669 616 === Realized? 617 618 <enscript highlight=scheme> 619 (Realized? seq) 670 ==== Realized? 671 672 <procedure>(Realized? seq)</procedure> 673 674 <enscript highlight=scheme> 620 675 (domain (%List? seq)) 621 676 (range (boolean? result)) … … 624 679 Is seq realized? 625 680 626 === Primes 627 628 <enscript highlight=scheme> 629 (Primes) 681 ==== Primes 682 683 <procedure>(Primes)</procedure> 684 685 <enscript highlight=scheme> 630 686 (range (%List? result) (not (%Length result))) 631 687 </enscript> … … 633 689 lazy list of non prime numbers 634 690 635 === Cardinals 636 637 <enscript highlight=scheme> 638 (Cardinals) 691 ==== Cardinals 692 693 <procedure>(Cardinals)</procedure> 694 695 <enscript highlight=scheme> 639 696 (range (%List? result) (not (%Length result))) 640 697 </enscript> … … 642 699 lazy list of non negative integers 643 700 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> 648 706 (domain (integer? from) (integer? upto)) 649 707 (range (%List result) (= (%Length result) (abs ( upto from)))) … … 655 713 656 714 <enscript highlight=scheme> 657 658 715 (use lazylists contracts) 716 </enscript> 659 717 660 718 == Examples … … 860 918 == Updated 861 919 920 Aug 2, 2012 921 862 922 == License 863 923
Note: See TracChangeset
for help on using the changeset viewer.