Changeset 37129 in project


Ignore:
Timestamp:
01/26/19 15:54:24 (9 months ago)
Author:
Ivan Raikov
Message:

yasos collections: added g-zip (generator zip) routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/5/yasos/trunk/collections.scm

    r36586 r37129  
    22(module yasos-collections
    33
    4  (collection? random-access? empty? size gen-keys gen-elts
    5               do-elts do-keys do-items
    6               map-elts map-keys map-items
    7               for-each-key for-each-elt elt-ref elt-set! elt-take elt-drop
    8               reduce reduce* reduce-items reduce-items* sort! sort
    9               make-vector-generator list->generator vector->generator
    10               string->generator hash-table->generator
    11               g-map g-reduce g-find g-filter
    12               generator->lseq lseq-first lseq-rest
    13               )
    14  
     4  (collection? random-access? empty? size gen-keys gen-elts do-elts
     5   do-keys do-items map-elts map-keys map-items for-each-key for-each-elt
     6   elt-ref elt-set! elt-take elt-drop reduce reduce* reduce-items
     7   reduce-items* sort! sort make-vector-generator list->generator
     8   vector->generator string->generator hash-table->generator g-map
     9   g-reduce g-find g-filter g-zip generator->lseq lseq-first lseq-rest )
     10 
    1511 (import scheme (chicken base) (chicken format) srfi-69
    1612         (except yasos object object-with-ancestors))
     
    5046;; Collections may optionally implement:
    5147;; 1) random access operations:
    52 ;;
    5348;; elt-ref
    5449;; elt-set!
     50;; 2) selector operations:
    5551;; elt-take
    5652;; elt-drop
     
    570566      ))
    571567
     568  (define (g-zip gen . gs)
     569    (let recur ((ax '()))
     570      (let ((value (gen)))
     571        (if (eof-object? value)
     572            (reverse ax)
     573            (recur (cons (cons value (map (lambda (g) (g)) gs)) ax))
     574            ))
     575      ))
     576
    572577;;;; SRFI 127 lazy sequences
    573578;;; Convert a generator (procedure with no arguments) to an lseq
Note: See TracChangeset for help on using the changeset viewer.