Re: [Chicken-users] Re: Style Guide
Ivan Shmakov wrote: Sunnan [EMAIL PROTECTED] writes: (define (fib) (let loop ((a 1) (b 1)) (set! fib (lambda () (loop b (+ a b a)) This `set!' isn't necessary, compare: (define fib (let ((a 1) (b 1)) (lambda () (let ((saved a)) (set! a b) (set! b (+ saved b)) saved Yes, this is the longer, classic style. As a fib generator with only two counters, it works fine, but you have to save the entire state by hand with a set! for each original variable, and you also introduce an extra variable for the swap. Your version is probably faster, and probably more familiar to many programmers. I was just fascinated by the two perverse ideas of 1. freezing a delayed call to a named let 2. resetting/redefining the very function we're in (similar to some call/cc tricks) Both variants should be quite portable. (Especially on non-compilers.) Thanks. Sunnan ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Re: Style Guide
On Tue, Nov 06, 2007 at 08:47:25PM -0800, Elf wrote: really, it doesnt matter. theres plenty of code with both, its entirely a personal preference issue. Well, not exactly the question asked, but something I learned from reading Chicken's sources: $ csi -no-init .. #;1 (define square (let ((* *)) (lambda (x) (* x x #;2 (square 4) 16 #;3 (define (* . args) (apply + args)) #;4 (* 4 4) 8 #;5 (square 4) 16 #;6 (use numbers) ; introduces a new binding for * .. #;7 (square ) Error: (*) bad argument type: .. #;7 (* ) 1234567901234567901234567901234567901234320987654320987654320987654320987654321 (define bla (let ((blubb blubb)) (lambda (fasel) ...))) gives access to another namescope. Benedikt ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Eggs, again
On Thu, Oct 25, 2007 at 01:25:53PM -0300, Mario Domenech Goulart wrote: Something weird happened on 2007-10-23. From http://chicken.wiki.br/automated-builds/2007/10/23/salmonella-report we can see all the eggs release dates were set to the current date. It happened again: http://chicken.wiki.br/automated-builds/2007/11/07/salmonella-report/ Benedikt ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Re: Style Guide
On Wed, 7 Nov 2007, Benedikt Rosenau wrote: On Tue, Nov 06, 2007 at 08:47:25PM -0800, Elf wrote: really, it doesnt matter. theres plenty of code with both, its entirely a personal preference issue. Well, not exactly the question asked, but something I learned from reading Chicken's sources: $ csi -no-init .. #;1 (define square (let ((* *)) (lambda (x) (* x x #;2 (square 4) 16 #;3 (define (* . args) (apply + args)) #;4 (* 4 4) 8 #;5 (square 4) 16 #;6 (use numbers) ; introduces a new binding for * .. #;7 (square ) Error: (*) bad argument type: .. #;7 (* ) 1234567901234567901234567901234567901234320987654320987654320987654320987654321 (define bla (let ((blubb blubb)) (lambda (fasel) ...))) gives access to another namescope. Benedikt of course it does :) all closures have their own namescope, as you put it. what you demonstrated above is the trick of associating state with a lambda. :) -elf ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Re: Style Guide
On Wed, Nov 07, 2007 at 06:02:42AM -0800, Elf wrote: of course it does :) all closures have their own namescope, as you put it. Namescope is what I come up with when lacking caffeine. That bug has been fixed in the meantime. what you demonstrated above is the trick of associating state with a lambda. :) Yes. I mentioned it because newbies might follow the conversation. As far as the style guide is concerned, I think it is useful to keep the possibly differing semantics in mind: (define (bla blubb) ; accept all bindings as they are now ...) (define bla ; I need some original bindings here (let ((...)) (lambda (blubb) ...))) So, (define (bla blubb) ...) is my default. I agree with all the reasons you gave. NB: the Chicken compiler assumes standard bindings by default. Hence, redefining * will work in csi, but it will not work, if compiled without (declare (not standard-bindings *)). Benedikt ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: cross-compilation, part II - Re: [Chicken-users] cross compilation with 2.7
Great, that did the trick! I can cross compile extensions again. Mucho thanks, John. On 07/11/2007, felix winkelmann [EMAIL PROTECTED] wrote: Replace TARGET_CC and TARGET_CXX with TARGET_C_COMPILER and TARGET_CXX_COMPILER, respectively. Alternatively, put .../cross/bin into your path and set TARGET=arm-angstrom-linux-gnueabi. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] ok my second egg is ready
hi my second egg is ready. I will add document from wiki later. all test cases passed. thanks grobner-basis.egg Description: Binary data ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] array-lib : prepending unit axes
On Nov 4, 2007, at 3:41 PM, Terrence Brannon wrote: i wrote a function to prepend unit axes onto an array. this is oftentimes necessary to get arrays to the same rank before applying some sort of operation to them. if there is a better way to do this, I'm all ears. Please, no comments about my parenthesizing style :) (define prepend-unit-axes (lambda (n a) (if (= n 0) a (let* ( [ones (make-list n 1)] [new-dim (flatten ones (array-dimensions a))] [as-v (array-vector a)] [as-l (vector-list as-v)] ) (apply array '#() new-dim as-l) Faster: (use srfi-1) (define (prepend-unit-axes cnt arr) (if (positive? cnt) (apply vector-array (array-vector arr) arr ; Use same storage as source array (append! (make-list cnt 1) (array- dimensions arr))) arr ) ) Even faster: (define (prepend-unit-axes cnt arr) (if (positive? cnt) (apply make-shared-array arr (lambda idxs (drop idxs cnt)) (append! (make-list cnt 1) (array- dimensions arr))) arr ) ) ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users Best Wishes, Kon ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users