From: "Ashish Shrestha" <address@hidden
Subject: [Chicken-users] photo album in chicken
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Chicken scripts to generate a HTML gallery. Something I wrote to learn
scheme so is less scheme than most would like to see. Yes I know I
have a lot to learn so would love to get feedback on the code.
The album uses Lightbox JS and sample albums are at
http://axhixh.homelinux.com/ Specially the new albums.
The source is available at
Would love to hear about the code. What is the correct way to handle
errors and an issue with memory. I run out of memory and the script
hangs when I am working with large (5 mega pix or higher) images.
Process a few images before it runs out of memory. How do I run the
script so it has more memory? How do I ensure that I release the
unused memory or more correctly, I don't hang on to stuffs that I have
It looks pretty good. But how are you indenting your code? What editor are you using? The indentation is both unconvential and inconsistent. If you're counting parentheses and/or indenting by hand, you should get a real editor, like Emacs.
Also, here is a more schemely and more compact normalise-path function:
(define (rps-normalise-path path)
(let loop ((reverse-parts (reverse (string-split path "/")))
(() (string-join acc "/"))
(("." . more) (loop more skip acc))
((".." . more) (loop more (add1 skip) acc))
((path-part . more)
(if (zero? skip)
(loop more 0 (cons path-part acc))
(loop more (sub1 skip) acc))))))
This version handles paths with "../../", but drops the leading "/" from absolute paths (so did yours).
Also, you wrote things like (display (format "foo...~A" foo)). It's slightly cleaner and more convenient to do either (printf "foo...~A" foo) or (print "foo.." foo).