Changeset 33584 in project
 Timestamp:
 08/12/16 17:03:38 (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/srfi133
r33577 r33584 65 65 66 66 <enscript highlight="scheme"> 67 (vectorunfold ( Î»(i x) (values x ( x 1)))67 (vectorunfold (lambda (i x) (values x ( x 1))) 68 68 10 0) 69 69 ;=> #(0 1 2 3 4 5 6 7 8 9) … … 80 80 81 81 <enscript highlight="scheme"> 82 (vectorunfold ( Î»(i) (vectorref vector i))82 (vectorunfold (lambda (i) (vectorref vector i)) 83 83 (vectorlength vector)) 84 84 </enscript> … … 96 96 97 97 <enscript highlight="scheme"> 98 (vectorunfoldright ( Î»(i x) (values (cons i x) (+ x 1))) 5 0)98 (vectorunfoldright (lambda (i x) (values (cons i x) (+ x 1))) 5 0) 99 99 ;=> #((0 . 4) (1 . 3) (2 . 2) (3 . 1) (4 . 0)) 100 100 </enscript> … … 103 103 104 104 <enscript highlight="scheme"> 105 (vectorunfoldright ( Î»(i x) (values (vectorref vector x) (+ x 1)))105 (vectorunfoldright (lambda (i x) (values (vectorref vector x) (+ x 1))) 106 106 (vectorlength vector) 107 107 0) … … 304 304 Find the longest string's length in vectorofstrings. 305 305 <enscript highlight="scheme"> 306 (vectorfold ( Î»(len str) (max (stringlength str) len))306 (vectorfold (lambda (len str) (max (stringlength str) len)) 307 307 0 vectorofstrings) 308 308 </enscript> … … 310 310 Produce a list of the reversed elements of vec. 311 311 <enscript highlight="scheme"> 312 (vectorfold ( Î»(tail elt) (cons elt tail))312 (vectorfold (lambda (tail elt) (cons elt tail)) 313 313 '() vec) 314 314 </enscript> … … 316 316 Count the number of even numbers in vec. 317 317 <enscript highlight="scheme"> 318 (vectorfold ( Î»(counter n)318 (vectorfold (lambda (counter n) 319 319 (if (even? n) (+ counter 1) counter)) 320 320 0 vec) … … 330 330 Convert a vector to a list. 331 331 <enscript highlight="scheme"> 332 (vectorfoldright ( Î»(tail elt) (cons elt tail))332 (vectorfoldright (lambda (tail elt) (cons elt tail)) 333 333 '() '#(a b c d)) 334 334 ;=> (a b c d) … … 345 345 346 346 <enscript highlight="scheme"> 347 (vectormap ( Î»(x) (* x x))348 (vectorunfold ( Î»(i x) (values x (+ x 1))) 4 1))347 (vectormap (lambda (x) (* x x)) 348 (vectorunfold (lambda (i x) (values x (+ x 1))) 4 1)) 349 349 ;=> #(1 4 9 16) 350 350 351 (vectormap ( Î»(x y) (* x y))352 (vectorunfold ( Î»(x) (values x (+ x 1))) 5 1)353 (vectorunfold ( Î»(x) (values x ( x 1))) 5 5))351 (vectormap (lambda (x y) (* x y)) 352 (vectorunfold (lambda (x) (values x (+ x 1))) 5 1) 353 (vectorunfold (lambda (x) (values x ( x 1))) 5 5)) 354 354 ;=> #(5 8 9 8 5) 355 355 356 356 (let ((count 0)) 357 (vectormap ( Î»(ignoredelt)357 (vectormap (lambda (ignoredelt) 358 358 (set! count (+ count 1)) 359 359 count) … … 381 381 382 382 <enscript highlight="scheme"> 383 (vectorforeach ( Î»(x) (display x) (newline))383 (vectorforeach (lambda (x) (display x) (newline)) 384 384 '#("foo" "bar" "baz" "quux" "zot")) 385 385 </enscript> … … 452 452 453 453 <enscript highlight="scheme"> 454 (vectorindex ( Î»(x1 x2 ...) (not (pred? x1 x1 ...)))454 (vectorindex (lambda (x1 x2 ...) (not (pred? x1 x1 ...))) 455 455 vec1 vec2 ...) 456 456 </enscript> … … 470 470 471 471 <enscript highlight="scheme"> 472 (vectorindexright ( Î»(x1 x2 ...) (not (pred? x1 x1 ...)))472 (vectorindexright (lambda (x1 x2 ...) (not (pred? x1 x1 ...))) 473 473 vec1 vec2 ...) 474 474 </enscript> … … 487 487 488 488 <enscript highlight="scheme"> 489 ( Î»(char1 char2)489 (lambda (char1 char2) 490 490 (cond ((char<? char1 char2) 1) 491 491 ((char=? char1 char2) 0)
Note: See TracChangeset
for help on using the changeset viewer.