Re: BBWT
On Sun, Feb 26, 2017 at 06:00:28PM +0100, Joh-Tob Schäg wrote: > > Yes, gotta love lisp for the ability to do this (and other things). :) > > > But more often than not this features are not required in practice. Sadly > it is just cool and not significant. :( I would say it is very significant. Factoring the code gives shorter, faster and more readable programs by avoiding duplicated code and redundancies. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: BBWT
> Yes, gotta love lisp for the ability to do this (and other things). :) > But more often than not this features are not required in practice. Sadly it is just cool and not significant. :( 2017-02-26 17:06 GMT+01:00 Rick Hanson : > A bit off-topic, but I like how this transformation > > On 25 Feb 2017, 09:40:43 +0100, Alexander Burger wrote: > >(if (not (cdr W)) > > (Put C (car W)) > > (Put (car (cdr W)) (car W)) ) > > -> > >(Put > > (ifn (cdr W) C (cadr W)) > > (car W) ) > > reminds me of factoring in high school algebra. > >xy + xz > -> >x(y + z) > > Yes, gotta love lisp for the ability to do this (and other things). :) > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
Re: BBWT
A bit off-topic, but I like how this transformation On 25 Feb 2017, 09:40:43 +0100, Alexander Burger wrote: >(if (not (cdr W)) > (Put C (car W)) > (Put (car (cdr W)) (car W)) ) > -> >(Put > (ifn (cdr W) C (cadr W)) > (car W) ) reminds me of factoring in high school algebra. xy + xz -> x(y + z) Yes, gotta love lisp for the ability to do this (and other things). :) -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: BBWT
Thanks Alex, The feedback is appreciated. This is a good clarification of how namespaces work in the 64bit version. Also, somehow, it had not 'clicked' with me that transient symbols could be used in this regard. Re-read that section of the documentation again... =) "With that mechanism, it is possible to create symbols with a local access scope, not accessible from other parts of the program" /Lindsay On Sat, Feb 25, 2017 at 12:40 AM, Alexander Burger wrote: > Hi Lindsay, > > > Bijective Burrows Wheeler Transform > > https://github.com/thinknlive/picolisp-bbwt > > Cool! This code looks very good! :) > > > > As I was working on this I realized I need to start thinking about how to > > organize my code... > > > > The two main functions, encodeBBWT and decodeBBWT feel larger than they > > should be because I have defined smaller functions within them that use > > variables in the same scope. > > > > My question: Is there an 'idiomatic' or recommended way to organize > module > > or project code in picolisp? > > Binding the functions 'Put' and 'Bwt' locally is perfectly legal, but not > really > necessary here, as they never change. So they just create (minimal) runtime > overhead. I would define them the normal way, perhaps as transient symbols > if I > want to hide them from the outside world: > >(de "put" (B C) > (let (V ... > >(de "bwt" (W) > (let (C ... > > > Using a namespace is also possible, but too much overhead in my feeling > for such > a small file. It would go like this: > >(symbols 'bbwt 'pico) >(local put bwt) > >(de put (B C) # Shadows the built-in 'put', use with care > (let (V ... > >(de bwt (W) > (let (C ... > >(de pico~encodeBBWT (L) > ... > >(de pico~decodeBBWT (L) > ... > > This creates the symbol 'encodeBBWT' in the 'pico' namespace. Another (I > think > better) way is: > >(de encode (L) > ... > >(de decode (L) > ... > > and later, when used from another namespace, call it as > >(bbwt~encode ...) >(bbwt~decode ...) > > > Concerning 'Debug', I would omit it here, and call (trace 'encodeBBWT) or > (trace > 'bbwt~encode) or (mapc trace '(bbwt~encode bbwt~decode bbwt~put bbwt~bwt) > to > debug it. > > Other minor improvements: > > V2 (car (cdr V)) ) > -> > V2 (cadr V) ) > > >(while (car W) > (if (not (cdr W)) > (Put C (car W)) > (Put (car (cdr W)) (car W)) ) > -> >(while (car W) > (Put > (ifn (cdr W) C (cadr W)) > (car W) ) > > and some similar cases :) > > ♪♫ Alex > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >
Re: BBWT
Hi Lindsay, > Bijective Burrows Wheeler Transform > https://github.com/thinknlive/picolisp-bbwt Cool! This code looks very good! :) > As I was working on this I realized I need to start thinking about how to > organize my code... > > The two main functions, encodeBBWT and decodeBBWT feel larger than they > should be because I have defined smaller functions within them that use > variables in the same scope. > > My question: Is there an 'idiomatic' or recommended way to organize module > or project code in picolisp? Binding the functions 'Put' and 'Bwt' locally is perfectly legal, but not really necessary here, as they never change. So they just create (minimal) runtime overhead. I would define them the normal way, perhaps as transient symbols if I want to hide them from the outside world: (de "put" (B C) (let (V ... (de "bwt" (W) (let (C ... Using a namespace is also possible, but too much overhead in my feeling for such a small file. It would go like this: (symbols 'bbwt 'pico) (local put bwt) (de put (B C) # Shadows the built-in 'put', use with care (let (V ... (de bwt (W) (let (C ... (de pico~encodeBBWT (L) ... (de pico~decodeBBWT (L) ... This creates the symbol 'encodeBBWT' in the 'pico' namespace. Another (I think better) way is: (de encode (L) ... (de decode (L) ... and later, when used from another namespace, call it as (bbwt~encode ...) (bbwt~decode ...) Concerning 'Debug', I would omit it here, and call (trace 'encodeBBWT) or (trace 'bbwt~encode) or (mapc trace '(bbwt~encode bbwt~decode bbwt~put bbwt~bwt) to debug it. Other minor improvements: V2 (car (cdr V)) ) -> V2 (cadr V) ) (while (car W) (if (not (cdr W)) (Put C (car W)) (Put (car (cdr W)) (car W)) ) -> (while (car W) (Put (ifn (cdr W) C (cadr W)) (car W) ) and some similar cases :) ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
BBWT
Bijective Burrows Wheeler Transform https://github.com/thinknlive/picolisp-bbwt As I was working on this I realized I need to start thinking about how to organize my code... The two main functions, encodeBBWT and decodeBBWT feel larger than they should be because I have defined smaller functions within them that use variables in the same scope. My question: Is there an 'idiomatic' or recommended way to organize module or project code in picolisp? /Lindsay P.S. I haven't paid much attention to namespaces or module management in picolisp until now so I'll spend some time reading the docs with that in mind.