[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] ftl egg
From: |
Thomas Christian Chust |
Subject: |
Re: [Chicken-users] ftl egg |
Date: |
Fri, 29 Jun 2007 10:16:45 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.4) Gecko/20070509 SeaMonkey/1.1.2 |
felix winkelmann wrote:
> [...]
> If you have any suggestions for algorithms and functions to add, please
> tell us so.
> [...]
Hello Felix,
playing around with the ftl egg, I noticed the following behaviour that
looks broken to me:
- The interfaces v=vector and v=string contain length methods that
return an element of the vector / string instead of its length.
- The interfaces i=reverse-vector, i=reverse=string and i=reverse-%v
don't transverse their input from the end but rather return
(length <input>) times the first element.
A patch against the current subversion trunk fixing these things is
attached to the e-mail.
Additionally I suggest the following handy output and accumulator
interfaces:
;;; A string output collector.
(define o=string
(o-interface
;; create
(lambda (#!optional dst)
(or dst ""))
;; write
(lambda (obj out)
(conc out obj))
;; result
identity))
(define a=string
(a=%o o=string))
cu,
Thomas
--
Murphy's Law is recursive. Washing your car to make it rain doesn't work.
Index: ftl.scm
===================================================================
--- ftl.scm (revision 4762)
+++ ftl.scm (working copy)
@@ -505,9 +505,10 @@
(unwrap
in
(lambda (data start end)
- (if (fx< end start)
+ (if (fx>= start end)
(values)
- (values (v-ref data start) (sub data start (fx- end 1)))))))))
+ (let ((i (fx- end 1)))
+ (values (v-ref data i) (sub data start i)))))))))
(define i=list
(i-interface
@@ -532,9 +533,10 @@
(unwrap
in
(lambda (d s e)
- (if (fx< e s)
+ (if (fx>= s e)
(values)
- (values (vector-ref d s) (sub d s (fx- e 1)))))))))
+ (let ((i (fx- e 1)))
+ (values (vector-ref d i) (sub d s i)))))))))
(define i=string
(i-interface
@@ -552,9 +554,10 @@
(unwrap
in
(lambda (d s e)
- (if (fx< e s)
+ (if (fx>= s e)
(values)
- (values (string-ref d s) (sub d s (fx- e 1)))))))))
+ (let ((i (fx- e 1)))
+ (values (string-ref d i) (sub d s i)))))))))
(define i=port
(i-interface
@@ -610,9 +613,10 @@
(unwrap
in
(lambda (data start end)
- (if (fx< end start)
+ (if (fx>= start end)
(values)
- (values (v-ref data start) (sub data start (fx- end 1)))))))
+ (let ((i (fx- end 1)))
+ (values (v-ref data i) (sub data start i)))))))
(lambda (in)
(unwrap
in
@@ -696,14 +700,14 @@
(define v=vector
(v-interface
(lambda (vec)
- (unwrap vec (lambda (d s e) (vector-ref d s))) )
+ (unwrap vec (lambda (d s e) (fx- e s))) )
(lambda (vec n)
(unwrap vec (lambda (d s e) (vector-ref d (fx+ s n))) ) ) ) )
(define v=string
(v-interface
(lambda (vec)
- (unwrap vec (lambda (d s e) (string-ref d s))) )
+ (unwrap vec (lambda (d s e) (fx- e s))) )
(lambda (vec n)
(unwrap vec (lambda (d s e) (string-ref d (fx+ s n))) ) ) ) )