Changeset 36271 in project


Ignore:
Timestamp:
08/15/18 00:11:44 (13 months ago)
Author:
felix winkelmann
Message:

sequences 0.5

Location:
release/5
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/5/egg-locations

    r36270 r36271  
    7676(sdl-base "http://code.call-cc.org/release-info?egg={egg-name};release={chicken-release}")
    7777(sendfile "https://bitbucket.org/certainty/sendfile/raw/tip/sendfile.release-info.chicken-5")
     78(sequences "http://code.call-cc.org/release-info?egg={egg-name};release={chicken-release}")
    7879(server-test "https://raw.github.com/mario-goulart/server-test/master/server-test.release-info")
    7980(sha1 "http://code.call-cc.org/release-info?egg={egg-name};release={chicken-release}")
  • release/5/sequences/tags/0.5/sequences.egg

    r36268 r36271  
    88 (dependencies fast-generic srfi-42)
    99 (components (extension sequences
    10                         (source "sequences-module.scm"))
     10                        (source "sequences-module.scm")
     11                        (source-dependencies "sequences.scm"))
    1112             (extension sequence-comprehensions
    1213                        (component-dependencies sequences)))
  • release/5/sequences/tags/0.5/sequences.scm

    r36268 r36271  
    103103(print (symbol-plist '<random-access-sequence>))
    104104
     105(define make-ras make-random-access-sequence)
     106
    105107(define make-random-access-sequence
    106   (let ((old make-random-access-sequence)
    107         (setter-tag (car (##sys#slot vector-ref 2)))) ; ugh
     108  (let ((old make-random-access-sequence))
    108109    (lambda (maker elt size)
    109110      (old
     
    113114       (maker 0 #f)))))
    114115
     116(define make-ls make-linear-sequence)
     117
    115118(define make-linear-sequence
    116   (let ((old make-linear-sequence)
    117         (setter-tag (car (##sys#slot vector-ref 2)))) ; ugh
     119  (let ((old make-linear-sequence))
    118120    (lambda (maker head next)
    119121      (old
     
    245247  ((<linear-sequence>)
    246248   (let ((maker (linear-sequence-make s)))
    247      (##sys#make-structure
    248       'linear-sequence
     249     (make-ls
    249250      maker
    250251      (linear-sequence-head s)
     
    253254  ((<random-access-sequence>)
    254255   (let ((maker (random-access-sequence-make s)))
    255      (##sys#make-structure
    256       'random-access-sequence
     256     (make-ras
    257257      maker
    258258      (random-access-sequence-elt s)
     
    292292          (newstate new (next newstate)))
    293293         ((fx>= i len)
    294           (##sys#make-structure 'linear-sequence make head next new))
     294          (make-ls make head next new))
    295295       (sethead newstate (head state)))))
    296296  ((<random-access-sequence>)
     
    308308             (set v2 j v)
    309309             (loop (fx+ i 1) (fx- j 1)))
    310            (##sys#make-structure 'random-access-sequence maker ref lenf v2))))))
     310           (make-ras maker ref lenf v2))))))
    311311
    312312(define-polymorphic (sub0 (x) start #!optional end)
     
    359359            (let loop ((hd hd) (j i) (s (linear-sequence-state new)))
    360360              (cond ((and end (fx>= j end))
    361                      (##sys#make-structure 'linear-sequence maker head next new))
     361                     (make-ls maker head next new))
    362362                    ((next hd) =>
    363363                     (lambda (nxt)
     
    381381          (j 0 (fx+ j 1)))
    382382         ((fx>= i end)
    383           (##sys#make-structure 'random-access-sequence maker ref size v2))
     383          (make-ras maker ref size v2))
    384384       (set v2 j (ref x i))))))
    385385
     
    538538
    539539(define-polymorphic (sequence (s) #!rest xs)
    540   ((<list>) xs)
     540  ((<list>)
     541   xs)
    541542  ((<linear-sequence>)
    542543   (let* ((maker (linear-sequence-make s))
     
    548549          (s new (next s)))
    549550         ((null? xs)
    550           (##sys#make-structure 'linear-sequence maker head next new))
     551          (make-ls maker head next new))
    551552       (sethead s (car xs)))))
    552553  ((any)
     
    592593     (let loop ((n new) (s (linear-sequence-state s)))
    593594       (if (not s)
    594            (##sys#make-structure 'linear-sequence make1 head1 next1 new)
     595           (make-ls make1 head1 next1 new)
    595596           (let ((x (proc (head2 s))))
    596597             (sethead1 n x)
     
    605606     (let loop ((i 0) (n new))
    606607       (if (fx>= i len)
    607            (##sys#make-structure 'linear-sequence make head next new)
     608           (make-ls make head next new)
    608609           (let ((x (proc (elt0-generic s i))))
    609610             (sethead n x)
  • release/5/sequences/tags/0.5/tests/run.scm

    r36268 r36271  
    22
    33
    4 (import sequences test srfi-1)
     4(import (rename sequences (take s-take) (drop s-drop)
     5                (partition s-partition)))
     6(import test)
     7(import srfi-1)
    58
    69
     
    166169(test #f (pos odd? '(2 4 6)))
    167170(test 2 (pos odd? '#(0 2 3 5)))
    168 (test '(1 2) (take positive? '(1 2 -3 4)))
    169 (test '(-3 1) (drop positive? '(5 2 -3 1)))
     171(test '(1 2) (s-take positive? '(1 2 -3 4)))
     172(test '(-3 1) (s-drop positive? '(5 2 -3 1)))
    170173(test '((4 5) (-1 2)) (receive (split positive? '(4 5 -1 2))))
    171174
    172 (test '(#(1 3) #(2 4)) (receive (partition odd? '#(1 2 3 4))))
     175(test '(#(1 3) #(2 4)) (receive (s-partition odd? '#(1 2 3 4))))
    173176
    174177(test '(a b c) (coerce '() (fill! (lambda (_ it) (index it)) r)))
     
    206209;;; comprehensions
    207210
    208 (use sequence-comprehensions srfi-42)
     211(import sequence-comprehensions srfi-42)
    209212
    210213(let ((i 1))
  • release/5/sequences/trunk/sequences.egg

    r36268 r36271  
    88 (dependencies fast-generic srfi-42)
    99 (components (extension sequences
    10                         (source "sequences-module.scm"))
     10                        (source "sequences-module.scm")
     11                        (source-dependencies "sequences.scm"))
    1112             (extension sequence-comprehensions
    1213                        (component-dependencies sequences)))
  • release/5/sequences/trunk/sequences.scm

    r36268 r36271  
    103103(print (symbol-plist '<random-access-sequence>))
    104104
     105(define make-ras make-random-access-sequence)
     106
    105107(define make-random-access-sequence
    106   (let ((old make-random-access-sequence)
    107         (setter-tag (car (##sys#slot vector-ref 2)))) ; ugh
     108  (let ((old make-random-access-sequence))
    108109    (lambda (maker elt size)
    109110      (old
     
    113114       (maker 0 #f)))))
    114115
     116(define make-ls make-linear-sequence)
     117
    115118(define make-linear-sequence
    116   (let ((old make-linear-sequence)
    117         (setter-tag (car (##sys#slot vector-ref 2)))) ; ugh
     119  (let ((old make-linear-sequence))
    118120    (lambda (maker head next)
    119121      (old
     
    245247  ((<linear-sequence>)
    246248   (let ((maker (linear-sequence-make s)))
    247      (##sys#make-structure
    248       'linear-sequence
     249     (make-ls
    249250      maker
    250251      (linear-sequence-head s)
     
    253254  ((<random-access-sequence>)
    254255   (let ((maker (random-access-sequence-make s)))
    255      (##sys#make-structure
    256       'random-access-sequence
     256     (make-ras
    257257      maker
    258258      (random-access-sequence-elt s)
     
    292292          (newstate new (next newstate)))
    293293         ((fx>= i len)
    294           (##sys#make-structure 'linear-sequence make head next new))
     294          (make-ls make head next new))
    295295       (sethead newstate (head state)))))
    296296  ((<random-access-sequence>)
     
    308308             (set v2 j v)
    309309             (loop (fx+ i 1) (fx- j 1)))
    310            (##sys#make-structure 'random-access-sequence maker ref lenf v2))))))
     310           (make-ras maker ref lenf v2))))))
    311311
    312312(define-polymorphic (sub0 (x) start #!optional end)
     
    359359            (let loop ((hd hd) (j i) (s (linear-sequence-state new)))
    360360              (cond ((and end (fx>= j end))
    361                      (##sys#make-structure 'linear-sequence maker head next new))
     361                     (make-ls maker head next new))
    362362                    ((next hd) =>
    363363                     (lambda (nxt)
     
    381381          (j 0 (fx+ j 1)))
    382382         ((fx>= i end)
    383           (##sys#make-structure 'random-access-sequence maker ref size v2))
     383          (make-ras maker ref size v2))
    384384       (set v2 j (ref x i))))))
    385385
     
    538538
    539539(define-polymorphic (sequence (s) #!rest xs)
    540   ((<list>) xs)
     540  ((<list>)
     541   xs)
    541542  ((<linear-sequence>)
    542543   (let* ((maker (linear-sequence-make s))
     
    548549          (s new (next s)))
    549550         ((null? xs)
    550           (##sys#make-structure 'linear-sequence maker head next new))
     551          (make-ls maker head next new))
    551552       (sethead s (car xs)))))
    552553  ((any)
     
    592593     (let loop ((n new) (s (linear-sequence-state s)))
    593594       (if (not s)
    594            (##sys#make-structure 'linear-sequence make1 head1 next1 new)
     595           (make-ls make1 head1 next1 new)
    595596           (let ((x (proc (head2 s))))
    596597             (sethead1 n x)
     
    605606     (let loop ((i 0) (n new))
    606607       (if (fx>= i len)
    607            (##sys#make-structure 'linear-sequence make head next new)
     608           (make-ls make head next new)
    608609           (let ((x (proc (elt0-generic s i))))
    609610             (sethead n x)
  • release/5/sequences/trunk/tests/run.scm

    r36268 r36271  
    22
    33
    4 (import sequences test srfi-1)
     4(import (rename sequences (take s-take) (drop s-drop)
     5                (partition s-partition)))
     6(import test)
     7(import srfi-1)
    58
    69
     
    166169(test #f (pos odd? '(2 4 6)))
    167170(test 2 (pos odd? '#(0 2 3 5)))
    168 (test '(1 2) (take positive? '(1 2 -3 4)))
    169 (test '(-3 1) (drop positive? '(5 2 -3 1)))
     171(test '(1 2) (s-take positive? '(1 2 -3 4)))
     172(test '(-3 1) (s-drop positive? '(5 2 -3 1)))
    170173(test '((4 5) (-1 2)) (receive (split positive? '(4 5 -1 2))))
    171174
    172 (test '(#(1 3) #(2 4)) (receive (partition odd? '#(1 2 3 4))))
     175(test '(#(1 3) #(2 4)) (receive (s-partition odd? '#(1 2 3 4))))
    173176
    174177(test '(a b c) (coerce '() (fill! (lambda (_ it) (index it)) r)))
     
    206209;;; comprehensions
    207210
    208 (use sequence-comprehensions srfi-42)
     211(import sequence-comprehensions srfi-42)
    209212
    210213(let ((i 1))
Note: See TracChangeset for help on using the changeset viewer.