1 | [[tags: egg]] |
---|
2 | [[toc:]] |
---|
3 | |
---|
4 | == Eager and lazy lists united |
---|
5 | |
---|
6 | This is an attempt to unify eager and lazy list. To use this egg you |
---|
7 | should carefully note the following |
---|
8 | |
---|
9 | === Rationale |
---|
10 | |
---|
11 | * All routines start uppercase. |
---|
12 | |
---|
13 | Hence they don't interfere with ordinary list routines. |
---|
14 | |
---|
15 | * The order of arguments is consistent. |
---|
16 | |
---|
17 | Procedure arguments first, list arguments last. |
---|
18 | For example, there is no List-ref routine, use At instead. |
---|
19 | |
---|
20 | * Most routines are defined in curried and uncurried form. |
---|
21 | |
---|
22 | So, curried versions can be used in Map and friends. |
---|
23 | The documentation shows both signatures, but explains only the |
---|
24 | uncurried form. |
---|
25 | |
---|
26 | * Biglists are either eager or lazy. |
---|
27 | |
---|
28 | * Lazy biglists are either finite or infinite. |
---|
29 | |
---|
30 | * All biglists are basically constructed with the macro Cons. |
---|
31 | |
---|
32 | This macro has two arguments for eager biglists, and an additional third |
---|
33 | argument, finite?, for lazy biglists. |
---|
34 | |
---|
35 | * The empty lazy biglist is the eos objects. |
---|
36 | |
---|
37 | * The emppy eager biglist is '(), as usual. |
---|
38 | |
---|
39 | * There are no Car and Cdr routines, but First and Rest instead. |
---|
40 | |
---|
41 | They behave differently: First returns eos at the empty biglist, and Rest |
---|
42 | returns itself at the empty biglist. |
---|
43 | Hence At can access even finite biglists at any position, it would |
---|
44 | simply return eos past the length of finite biglists. |
---|
45 | |
---|
46 | * Pattern matching on biglists is available via the bindings egg. |
---|
47 | |
---|
48 | To achieve that, bind-seq-db is already updated. |
---|
49 | |
---|
50 | * List comprehensions work as well for biglists. |
---|
51 | |
---|
52 | This is provided by the For macro. |
---|
53 | |
---|
54 | === Documentation |
---|
55 | |
---|
56 | Note, that the signatures of curried and uncurried versions are listed, |
---|
57 | but only the uncurried ones are described. |
---|
58 | |
---|
59 | ==== biglists |
---|
60 | |
---|
61 | <procedure>(biglists)</procedure> |
---|
62 | <procedure>(biglists sym)</procedure> |
---|
63 | |
---|
64 | The first call returns the list of exported symbols, the second |
---|
65 | documentation for the exported symbol sym. |
---|
66 | |
---|
67 | ==== Append |
---|
68 | |
---|
69 | <procedure>(Append xs . xss)</procedure> |
---|
70 | |
---|
71 | appends all argument lists, provided all but the last |
---|
72 | are finite |
---|
73 | |
---|
74 | ==== Assoc |
---|
75 | |
---|
76 | <procedure>(Assoc key)</procedure> |
---|
77 | <procedure>(Assoc key xs)</procedure> |
---|
78 | |
---|
79 | returns the biglist, whose First or car is Equal? to key |
---|
80 | |
---|
81 | ==== Assp |
---|
82 | |
---|
83 | <procedure>(Assp ok?)</procedure> |
---|
84 | <procedure>(Assp ok? xs)</procedure> |
---|
85 | |
---|
86 | returns the biglist, whose First or car passes ok? |
---|
87 | |
---|
88 | ==== Assq |
---|
89 | |
---|
90 | <procedure>(Assq key)</procedure> |
---|
91 | <procedure>(Assq key xs)</procedure> |
---|
92 | |
---|
93 | returns the biglist, whose First or car is Eq? to key |
---|
94 | |
---|
95 | ==== Assv |
---|
96 | |
---|
97 | <procedure>(Assv key)</procedure> |
---|
98 | <procedure>(Assv key xs)</procedure> |
---|
99 | |
---|
100 | returns the biglist, whose First or car is Eqv? to key |
---|
101 | |
---|
102 | ==== At |
---|
103 | |
---|
104 | <procedure>(At k)</procedure> |
---|
105 | <procedure>(At k xs)</procedure> |
---|
106 | |
---|
107 | returns the kth item of xs |
---|
108 | |
---|
109 | ==== BigList? |
---|
110 | |
---|
111 | <procedure>(BigList? xpr)</procedure> |
---|
112 | |
---|
113 | type predicate |
---|
114 | |
---|
115 | ==== BigList->list |
---|
116 | |
---|
117 | <procedure>(BigList->list xs)</procedure> |
---|
118 | <procedure>(BigList->list k xs)</procedure> |
---|
119 | |
---|
120 | transforms a possibly infinite biglist xs into a list |
---|
121 | |
---|
122 | ==== Cons |
---|
123 | |
---|
124 | <macro>(Cons x y finite?)</macro> |
---|
125 | <macro>(Cons x y)</macro> |
---|
126 | |
---|
127 | returns either a lazy or an eager biglist |
---|
128 | |
---|
129 | ==== Cycle |
---|
130 | |
---|
131 | <procedure>(Cycle xs)</procedure> |
---|
132 | |
---|
133 | returns an infinite biglist by appending the finite |
---|
134 | biglist xs over and over |
---|
135 | |
---|
136 | ==== Cycle-times |
---|
137 | |
---|
138 | <procedure>(Cycle k xs)</procedure> |
---|
139 | |
---|
140 | returns a finite biglist by appending the finite |
---|
141 | biglist xs k times |
---|
142 | |
---|
143 | ==== Drop |
---|
144 | |
---|
145 | <procedure>(Drop k)</procedure> |
---|
146 | <procedure>(Drop k xs)</procedure> |
---|
147 | |
---|
148 | drops the first k items of xs |
---|
149 | |
---|
150 | ==== Drop-while |
---|
151 | |
---|
152 | <procedure>(Drop-while ok?)</procedure> |
---|
153 | <procedure>(Drop-while ok? xs)</procedure> |
---|
154 | |
---|
155 | returns the xs whith those front items x removed |
---|
156 | which pass ok? |
---|
157 | |
---|
158 | ==== Drop-until |
---|
159 | |
---|
160 | <procedure>(Drop-until ok?)</procedure> |
---|
161 | <procedure>(Drop-until ok? xs)</procedure> |
---|
162 | |
---|
163 | returns the xs whith those front items x removed |
---|
164 | which don't pass ok? |
---|
165 | |
---|
166 | ==== Eager? |
---|
167 | |
---|
168 | <procedure>(Eager? xpr)</procedure> |
---|
169 | |
---|
170 | is xpr an eager biglist, i.e. a normal list? |
---|
171 | |
---|
172 | ==== Eq? |
---|
173 | |
---|
174 | <procedure>(Eq? xs ys)</procedure> |
---|
175 | |
---|
176 | returns #t if both lists have same length |
---|
177 | and corresponding items are eq? |
---|
178 | |
---|
179 | ==== Eqp? |
---|
180 | |
---|
181 | <procedure>(Eqp? =?)</procedure> |
---|
182 | <procedure>(Eqp? =? xs ys)</procedure> |
---|
183 | |
---|
184 | returns #t if both lists have same length |
---|
185 | and corresponding items are =? |
---|
186 | |
---|
187 | ==== Equal? |
---|
188 | |
---|
189 | <procedure>(Equal? xs ys)</procedure> |
---|
190 | |
---|
191 | returns #t if both lists have same length |
---|
192 | and corresponding items are equal? |
---|
193 | |
---|
194 | ==== Eqv? |
---|
195 | |
---|
196 | <procedure>(Eqv? xs ys)</procedure> |
---|
197 | |
---|
198 | returns #t if both lists have same length |
---|
199 | and corresponding items are eqv? |
---|
200 | |
---|
201 | ==== Every? |
---|
202 | |
---|
203 | <procedure>(Every? ok?)</procedure> |
---|
204 | <procedure>(Every? ok? xs)</procedure> |
---|
205 | |
---|
206 | returns #t if every item of the finite biglist xs |
---|
207 | passes the ok? test |
---|
208 | |
---|
209 | ==== Filter |
---|
210 | |
---|
211 | <procedure>(Filter ok?)</procedure> |
---|
212 | <procedure>(Filter ok? xs)</procedure> |
---|
213 | |
---|
214 | removes all items from the biglist xs which |
---|
215 | do not pass the ok? test |
---|
216 | |
---|
217 | ==== Fold-left |
---|
218 | |
---|
219 | <procedure>(Fold-left op init)</procedure> |
---|
220 | <procedure>(Fold-left op init . xss)</procedure> |
---|
221 | |
---|
222 | folds the finite biglists xss from the left |
---|
223 | |
---|
224 | ==== Fold-left0 |
---|
225 | |
---|
226 | <procedure>(Fold-left0 op)</procedure> |
---|
227 | <procedure>(Fold-left0 op . xss)</procedure> |
---|
228 | |
---|
229 | folds the finite biglists<procedure>(map Rest xss) from the left |
---|
230 | with init<procedure>(map First xss)</procedure> |
---|
231 | |
---|
232 | ==== Fold-right |
---|
233 | |
---|
234 | <procedure>(Fold-right op init)</procedure> |
---|
235 | <procedure>(Fold-right op init . xss)</procedure> |
---|
236 | |
---|
237 | folds the finite biglists xss from the right |
---|
238 | |
---|
239 | ==== Fold-right0 |
---|
240 | |
---|
241 | <procedure>(Fold-right0 op)</procedure> |
---|
242 | <procedure>(Fold-right0 op . xss)</procedure> |
---|
243 | |
---|
244 | folds the finite biglists<procedure>(map Rest xss) from the right |
---|
245 | with init<procedure>(map First xss)</procedure> |
---|
246 | |
---|
247 | ==== For |
---|
248 | |
---|
249 | <macro>(For ((var xs ok? ...) ....) item)</macro> |
---|
250 | |
---|
251 | creates a new list by binding var to each element |
---|
252 | of the list xs in sequence, and if it passes the checks, |
---|
253 | ok? ..., inserts item into the result list. |
---|
254 | The qualifieres, (var xs ok? ...), are processed |
---|
255 | sequentially from left to right, so that filters of a |
---|
256 | qualifier have access to the variables of qualifiers |
---|
257 | to its left. |
---|
258 | |
---|
259 | ==== For-each |
---|
260 | |
---|
261 | <procedure>(For-each fn)</procedure> |
---|
262 | <procedure>(For-each fn . xss)</procedure> |
---|
263 | |
---|
264 | applies the procedure fn to each list of items |
---|
265 | of xss at each commeon index |
---|
266 | |
---|
267 | ==== First |
---|
268 | |
---|
269 | <procedure>(First xs)</procedure> |
---|
270 | |
---|
271 | returns the front item of xs, which might be eos, |
---|
272 | if xs is empty |
---|
273 | |
---|
274 | ==== Index |
---|
275 | |
---|
276 | <procedure>(Index ok?)</procedure> |
---|
277 | <procedure>(Index ok? xs)</procedure> |
---|
278 | |
---|
279 | returns the index of the first item of the biglist xs, |
---|
280 | which passes the ok? test |
---|
281 | |
---|
282 | ==== Iterate |
---|
283 | |
---|
284 | <procedure>(Iterate fn)</procedure> |
---|
285 | <procedure>(Iterate fn x)</procedure> |
---|
286 | |
---|
287 | returns an infinite list by iteratively |
---|
288 | applying fn to x |
---|
289 | |
---|
290 | ==== Iterate-times |
---|
291 | |
---|
292 | <procedure>(Iterate-times fn times)</procedure> |
---|
293 | <procedure>(Iterate-times fn times x)</procedure> |
---|
294 | |
---|
295 | returns a finite list of lentgh times by |
---|
296 | iteratively applying fn to x |
---|
297 | |
---|
298 | ==== Iterate-until |
---|
299 | |
---|
300 | <procedure>(Iterate-until fn ok?)</procedure> |
---|
301 | <procedure>(Iterate-until fn ok? x)</procedure> |
---|
302 | |
---|
303 | returns a finite list by iteratively applying |
---|
304 | fn to x until ok? returns #t on the result |
---|
305 | |
---|
306 | ==== Iterate-while |
---|
307 | |
---|
308 | <procedure>(Iterate-while fn ok?)</procedure> |
---|
309 | |
---|
310 | returns a finite list by iteratively applying |
---|
311 | fn to x as long as ok? returns #t on the result |
---|
312 | |
---|
313 | ==== Lazy? |
---|
314 | |
---|
315 | <procedure>(Lazy? xpr)</procedure> |
---|
316 | |
---|
317 | is xpr a lazy biglist? |
---|
318 | |
---|
319 | ==== Length |
---|
320 | |
---|
321 | <procedure>(Length xs)</procedure> |
---|
322 | |
---|
323 | retuns the length of a finite biglist or #f |
---|
324 | of an infinite one |
---|
325 | |
---|
326 | ==== List |
---|
327 | |
---|
328 | <procedure>(List . args)</procedure> |
---|
329 | |
---|
330 | creates a lazy finite biglist with items args |
---|
331 | |
---|
332 | ==== List? |
---|
333 | |
---|
334 | <procedure>(List? xpr)</procedure> |
---|
335 | |
---|
336 | is xpr a finite biglist? |
---|
337 | |
---|
338 | ==== List-of? |
---|
339 | |
---|
340 | <procedure>(List-of? . oks?)</procedure> |
---|
341 | <procedure>(List-of? k . oks?)</procedure> |
---|
342 | |
---|
343 | returs a predicate on a biglist, which checks, |
---|
344 | if every item<procedure>(or Take k item) is a finite biglist |
---|
345 | |
---|
346 | ==== Map |
---|
347 | |
---|
348 | <procedure>(Map fn)</procedure> |
---|
349 | <procedure>(Map fn . xss)</procedure> |
---|
350 | |
---|
351 | maps every list of of items at fixed index of xss |
---|
352 | with function fn |
---|
353 | |
---|
354 | ==== Member |
---|
355 | |
---|
356 | <procedure>(Member x)</procedure> |
---|
357 | <procedure>(Member x xs)</procedure> |
---|
358 | |
---|
359 | returns the first tail af the biglist xs |
---|
360 | whose first item is equal? to x |
---|
361 | |
---|
362 | ==== Memp |
---|
363 | |
---|
364 | <procedure>(Memp ok?)</procedure> |
---|
365 | <procedure>(Memp ok? xs)</procedure> |
---|
366 | |
---|
367 | returns the first tail af the biglist xs |
---|
368 | which passes the ok? test |
---|
369 | |
---|
370 | ==== Memq |
---|
371 | |
---|
372 | <procedure>(Memq x)</procedure> |
---|
373 | <procedure>(Memq x xs)</procedure> |
---|
374 | |
---|
375 | returns the first tail af the biglist xs |
---|
376 | whose first item is eqv? to x |
---|
377 | |
---|
378 | ==== Memv |
---|
379 | |
---|
380 | <procedure>(Memv x)</procedure> |
---|
381 | <procedure>(Memv x xs)</procedure> |
---|
382 | |
---|
383 | returns the first tail af the biglist xs |
---|
384 | whose first item is eqv? to x |
---|
385 | |
---|
386 | ==== Merge |
---|
387 | |
---|
388 | <procedure>(Merge <? xs ys)</procedure> |
---|
389 | |
---|
390 | merges two finite finite biglists xs and ys, |
---|
391 | both lazy or both eager, with respect to <? |
---|
392 | |
---|
393 | ==== Null? |
---|
394 | |
---|
395 | <procedure>(Null? xs)</procedure> |
---|
396 | |
---|
397 | is the biglist xs empty? |
---|
398 | |
---|
399 | ==== Print |
---|
400 | |
---|
401 | <procedure>(Print k xs)</procedure> |
---|
402 | <procedure>(Print xs)</procedure> |
---|
403 | |
---|
404 | print the items of a finite biglist, |
---|
405 | or the first k items of an infinite one |
---|
406 | |
---|
407 | ==== Range |
---|
408 | |
---|
409 | <procedure>(Range upto)</procedure> |
---|
410 | <procedure>(Range from upto)</procedure> |
---|
411 | <procedure>(Range from upto step)</procedure> |
---|
412 | |
---|
413 | creates a list of numbers with given limits |
---|
414 | from defaults to 0 |
---|
415 | step defaults to 1 |
---|
416 | the list is infinite, if utpo is #f |
---|
417 | |
---|
418 | ==== Read-forever |
---|
419 | |
---|
420 | <procedure>(Read-forever)</procedure> |
---|
421 | |
---|
422 | creates an infinite biglist of prompted |
---|
423 | read procedures |
---|
424 | |
---|
425 | ==== Remove |
---|
426 | |
---|
427 | <procedure>(Remove x)</procedure> |
---|
428 | <procedure>(Remove x xs)</procedure> |
---|
429 | |
---|
430 | removes all items of the biglist xs, which |
---|
431 | are equal? to x |
---|
432 | |
---|
433 | ==== Remp |
---|
434 | |
---|
435 | <procedure>(Remp ok?)</procedure> |
---|
436 | <procedure>(Remp ok? xs)</procedure> |
---|
437 | |
---|
438 | removes all items of the biglist xs, which |
---|
439 | pass the ok? test |
---|
440 | |
---|
441 | ==== Remq |
---|
442 | |
---|
443 | <procedure>(Remp x)</procedure> |
---|
444 | <procedure>(Remp x xs)</procedure> |
---|
445 | |
---|
446 | removes all items of the biglist xs, which |
---|
447 | are eq? to x |
---|
448 | |
---|
449 | ==== Remv |
---|
450 | |
---|
451 | <procedure>(Remp x)</procedure> |
---|
452 | <procedure>(Remp x xs)</procedure> |
---|
453 | |
---|
454 | removes all items of the biglist xs, which |
---|
455 | are eqv? to x |
---|
456 | |
---|
457 | ==== Repeat |
---|
458 | |
---|
459 | <procedure>(Repeat x)</procedure> |
---|
460 | |
---|
461 | returns an infinite biglist with all items x |
---|
462 | |
---|
463 | ==== Repeat-times |
---|
464 | |
---|
465 | <procedure>(Repeat-times k x)</procedure> |
---|
466 | |
---|
467 | returns a finite biglist of length k with all items x |
---|
468 | |
---|
469 | ==== Rest |
---|
470 | |
---|
471 | <procedure>(Rest xs)</procedure> |
---|
472 | |
---|
473 | returns the rest of the biglist except the front item |
---|
474 | which might be xs itself, if empty |
---|
475 | |
---|
476 | ==== Reverse |
---|
477 | |
---|
478 | <procedure>(Reverse xs)</procedure> |
---|
479 | <procedure>(Reversee xs ys)</procedure> |
---|
480 | |
---|
481 | Append the reverse of xs to ys |
---|
482 | xs must be finite |
---|
483 | |
---|
484 | ==== Reverse* |
---|
485 | |
---|
486 | <procedure>(Reverse* xs)</procedure> |
---|
487 | |
---|
488 | retrurns the list of reverses of |
---|
489 | of all finite takes |
---|
490 | |
---|
491 | ==== Scan-left |
---|
492 | |
---|
493 | <procedure>(Scan-left op init)</procedure> |
---|
494 | <procedure>(Scan-left op init . xss)</procedure> |
---|
495 | |
---|
496 | returns a biglist, whose item at index k |
---|
497 | is the left fold of (map (Take k) xss) |
---|
498 | |
---|
499 | ==== Scan-right |
---|
500 | |
---|
501 | <procedure>(Scan-right op init)</procedure> |
---|
502 | <procedure>(Scan-right op init . xss)</procedure> |
---|
503 | |
---|
504 | returns a biglist, whose item at index k |
---|
505 | is the right fold of (map (Take k) xss) |
---|
506 | |
---|
507 | ==== Some? |
---|
508 | |
---|
509 | <procedure>(Some? ok?)</procedure> |
---|
510 | <procedure>(Some? ok? xs)</procedure> |
---|
511 | |
---|
512 | returns #t if some item of the finite biglist xs |
---|
513 | passes the ok? test |
---|
514 | |
---|
515 | ==== Sort |
---|
516 | |
---|
517 | <procedure>(Sort <?)</procedure> |
---|
518 | <procedure>(Sort <? xs)</procedure> |
---|
519 | |
---|
520 | sorts the finite biglist xs with respect to <? |
---|
521 | |
---|
522 | ==== Sorted? |
---|
523 | |
---|
524 | <procedure>(Sorted? <?)</procedure> |
---|
525 | <procedure>(Sorted? <? xs)</procedure> |
---|
526 | |
---|
527 | is the biglist xs finite and sorted? |
---|
528 | |
---|
529 | ==== Take |
---|
530 | |
---|
531 | <procedure>(Take k)</procedure> |
---|
532 | <procedure>(Take k xs)</procedure> |
---|
533 | |
---|
534 | returns the finite biglist of the first |
---|
535 | k items of the biglist xs |
---|
536 | |
---|
537 | ==== Take-until |
---|
538 | |
---|
539 | <procedure>(Take-until ok?)</procedure> |
---|
540 | <procedure>(Take-until ok? xs)</procedure> |
---|
541 | |
---|
542 | returns the finite biglist of the first |
---|
543 | items of the biglist xs, which do not pass |
---|
544 | the ok? test |
---|
545 | |
---|
546 | ==== Take-while |
---|
547 | |
---|
548 | <procedure>(Take-while ok?)</procedure> |
---|
549 | <procedure>(Take-while ok? xs)</procedure> |
---|
550 | |
---|
551 | returns the finite biglist of the first |
---|
552 | items of the biglist xs, which do pass |
---|
553 | the ok? test |
---|
554 | |
---|
555 | ==== Unzip |
---|
556 | |
---|
557 | <procedure>(Unzip xs)</procedure> |
---|
558 | |
---|
559 | returns two values, the sublists of biglist xs |
---|
560 | of even or uneven index |
---|
561 | |
---|
562 | ==== Zip |
---|
563 | |
---|
564 | <procedure>(Zip xs ys)</procedure> |
---|
565 | |
---|
566 | merges the biglists xs and ys by alternatively |
---|
567 | Consing (First xs) or (First ys) to the result |
---|
568 | biglist. Works for unfinite biglists as well. |
---|
569 | |
---|
570 | ==== eos |
---|
571 | |
---|
572 | end-of-sequence indicator |
---|
573 | |
---|
574 | === Dependencies |
---|
575 | |
---|
576 | bindings |
---|
577 | |
---|
578 | === Examples |
---|
579 | |
---|
580 | <enscript highlight=scheme> |
---|
581 | |
---|
582 | (import biglists bindings) |
---|
583 | |
---|
584 | (define ones (Cons 1 ones #f)) |
---|
585 | |
---|
586 | (First eos) ;-> eos |
---|
587 | |
---|
588 | (At 2 '(0 1 2 3 4)) ;-> 2 |
---|
589 | |
---|
590 | (At 3 (List 0 1 2 3 4) ;-> 3 |
---|
591 | |
---|
592 | (List? (List 0 1 2 3 4) ;-> #t |
---|
593 | |
---|
594 | (List? '(0 1 2 3 4)) ;-> #t |
---|
595 | |
---|
596 | (BigList->list (Take 4 integers)) ;-> '(0 1 2 3) |
---|
597 | |
---|
598 | (First (Drop 4 integers)) ;-> 4 |
---|
599 | |
---|
600 | (BigList->list (Reverse (List 0 1 2 3))) ;-> '(3 2 1 0) |
---|
601 | |
---|
602 | (Fold-right + 0 (List 1 2 3)) ;-> 6 |
---|
603 | |
---|
604 | (Fold-left + 0 '(1 2 3)) ;-> 6 |
---|
605 | |
---|
606 | (Length (Scan-right + 0 four four)) ;-> 4 |
---|
607 | |
---|
608 | (BigList->list 12 (Zip (List 0 1 2 3) integers)) |
---|
609 | ;-> '(0 0 1 1 2 2 3 3 4 5 6 7) |
---|
610 | |
---|
611 | (BigList->list 10 (nth-value 0 (Unzip integers))) |
---|
612 | ;-> '(0 2 4 6 8 10 12 14 16 18) |
---|
613 | |
---|
614 | (BigList->list 10 (nth-value 1 (Unzip integers))) |
---|
615 | ;-> '(1 3 5 7 9 11 13 15 17 19) |
---|
616 | |
---|
617 | (Merge <= '(0 1 2 3 4) '(0 1 2 3 4)) |
---|
618 | ;-> '(0 0 1 1 2 2 3 3 4 4) |
---|
619 | |
---|
620 | (BigList->list (Sort <= (Append (List 0 1 2 3) (List 0 1 2 3)))) |
---|
621 | ;-> '(0 0 1 1 2 2 3 3) |
---|
622 | |
---|
623 | (BigList->list 10 (Memv 3 integers)) |
---|
624 | ;-> '(3 4 5 6 7 8 9 10 11 12) |
---|
625 | |
---|
626 | (BigList->list (Assp odd? (List (List 0 5) (List 1 6) (List 2 7)))) |
---|
627 | ;-> '(1 6) |
---|
628 | |
---|
629 | (BigList->list 5 (Range #f)) ;-> '(0 1 2 3 4) |
---|
630 | |
---|
631 | (BigList->list (Iterate-times add1 5 1)) |
---|
632 | ;-> '(1 2 3 4 5) |
---|
633 | |
---|
634 | (bind (x . xs) integers (list x (BigList->list 5 xs))) |
---|
635 | ;-> '(0 (1 2 3 4 5)) |
---|
636 | |
---|
637 | (bind (x (y . ys) z) (List 1 integers 3) |
---|
638 | (list x y z (BigList->list 5 ys))) |
---|
639 | ;-> '(1 0 3 (1 2 3 4 5)) |
---|
640 | |
---|
641 | (BigList->list (For ((x (List 0 1 2 3)) (add1 x))) ; map |
---|
642 | ;-> '(1 2 3 4)) |
---|
643 | |
---|
644 | (BigList->list (For ((x (List 0 1 2 3 4 5 6) (odd? x))) x)) ; filter |
---|
645 | ;-> '(1 3 5)) |
---|
646 | |
---|
647 | (BigList->list (For ((n (List 0 1 2 3 4 5 6) (positive? n) (even? n))) |
---|
648 | (* 10 n))) |
---|
649 | ;-> '(20 40 60)) |
---|
650 | |
---|
651 | (BigList->list (For ((c (List 'A 'B 'C)) ;lazy |
---|
652 | (k '(1 2 3 4))) ;eager |
---|
653 | (list c k))) |
---|
654 | ;-> '((A 1) (A 2) (A 3) (A 4) |
---|
655 | ; (B 1) (B 2) (B 3) (B 4) |
---|
656 | ; (C 1) (C 2) (C 3) (C 4)) |
---|
657 | |
---|
658 | (For ((c '(A B C)) ;eager |
---|
659 | (k (List 1 2 3 4))) ;lazy |
---|
660 | (list c k)) |
---|
661 | ;-> '((A 1) (A 2) (A 3) (A 4) |
---|
662 | ; (B 1) (B 2) (B 3) (B 4) |
---|
663 | ; (C 1) (C 2) (C 3) (C 4)) |
---|
664 | |
---|
665 | </enscript> |
---|
666 | |
---|
667 | == Last update |
---|
668 | |
---|
669 | Mar 17, 2019 |
---|
670 | |
---|
671 | == Author |
---|
672 | |
---|
673 | [[/users/juergen-lorenz|Juergen Lorenz]] |
---|
674 | |
---|
675 | == License |
---|
676 | |
---|
677 | Copyright (c) 2014-2019, Juergen Lorenz |
---|
678 | All rights reserved. |
---|
679 | |
---|
680 | Redistribution and use in source and binary forms, with or without |
---|
681 | modification, are permitted provided that the following conditions are |
---|
682 | met: |
---|
683 | |
---|
684 | Redistributions of source code must retain the above copyright |
---|
685 | notice, this list of conditions and the following disclaimer. |
---|
686 | |
---|
687 | Redistributions in binary form must reproduce the above copyright |
---|
688 | notice, this list of conditions and the following disclaimer in the |
---|
689 | documentation and/or other materials provided with the distribution. |
---|
690 | Neither the name of the author nor the names of its contributors may be |
---|
691 | used to endorse or promote products derived from this software without |
---|
692 | specific prior written permission. |
---|
693 | |
---|
694 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
---|
695 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
---|
696 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
---|
697 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
698 | HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
699 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
---|
700 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
701 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
702 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
703 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
704 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
705 | |
---|
706 | == Version History |
---|
707 | |
---|
708 | ; 0.1 : initial import |
---|
709 | |
---|
710 | |
---|
711 | |
---|