From: JK on 2 Mar 2007 16:55 Ken Tilton wrote: [scissors of brevity] > I was anti-loop bigot for years, now I cannot even remember the syntax > of dolist. PG is a closet Schemer. Look at Arc. Pure minimalist. He does > not like CLOS either. Now it may be that /you/ are a latent Schemer and > that would be fine, but the spirit of Common Lisp is the more mud the > better. LOOP rocks. I put off learning LOOP for a long while, based on PG's assessment. I wrote iteration almost exclusively using recursion, due to long exposure to Prolog and some Scheme; and I find DO to be unreadable. Last weekend I learned LOOP just for the hell of it while writing a dinky little app, and damn if it isn't like crack -- I can't stop using it now! Every time I want to iterate, a LOOP form just pops into my brain. I was a little concerned about the efficiency of the code generated by LOOP, but it seems to all be TAGBODYs and GOs (at least in CLISP), which intuitively seems more efficient both speed- and space-wise than the recursive loops I used to write. (Though I'm aware intuition isn't necessarily a reliable guide to such things.) -- JK
From: Ken Tilton on 2 Mar 2007 17:53 JK wrote: > Ken Tilton wrote: > > [scissors of brevity] > >> I was anti-loop bigot for years, now I cannot even remember the syntax >> of dolist. PG is a closet Schemer. Look at Arc. Pure minimalist. He >> does not like CLOS either. Now it may be that /you/ are a latent >> Schemer and that would be fine, but the spirit of Common Lisp is the >> more mud the better. LOOP rocks. > > > I put off learning LOOP for a long while, based on PG's assessment. > I wrote iteration almost exclusively using recursion, due to long > exposure to Prolog and some Scheme; and I find DO to be unreadable. > Last weekend I learned LOOP just for the hell of it while writing > a dinky little app, and damn if it isn't like crack -- I can't > stop using it now! Every time I want to iterate, a LOOP form just > pops into my brain. Don't know how quick a study you are, but wait until you have it down code and can toss off a thereis without thinking twice, or do on vs. (in vs. across) without thinking! I guess there some Mavis Beacon showoffs out there who just forever typing lambda, not me. > > I was a little concerned about the efficiency of the code generated > by LOOP, but it seems to all be TAGBODYs and GOs (at least in CLISP), > which intuitively seems more efficient both speed- and space-wise > than the recursive loops I used to write. (Though I'm aware intuition > isn't necessarily a reliable guide to such things.) Actually, that is a big part of what turned me on to LOOP. I am pretty sure it expands into pretty optimal code. eg, collect keeping a record of the tail so not even a final nreverse is needed. And of course it makes sense that they would do it that way since it was menat to be a language extension. kt -- Well, I've wrestled with reality for 35 years, Doctor, and I'm happy to state I finally won out over it. -- Elwood P. Dowd In this world, you must be oh so smart or oh so pleasant. -- Elwood's Mom
From: Fred Gilham on 2 Mar 2007 19:20 It's fun to see all the different techniques people have brought to bear on this problem. I can imagine someone writing a programming book taking all these different programs and using them to illustrate various programming paradigms and methodologies. Here's an extensible version that uses a list of closures as filters. (defvar *fizzers* nil) (defun make-fizzer (n string) (lambda (i) (and (zerop (mod i n)) (princ string)))) ;; Obviously order matters here.... (push (make-fizzer 5 "Buzz") *fizzers*) (push (make-fizzer 3 "Fizz") *fizzers*) (defun map-fizzers (n) (map 'list (lambda (f) (funcall f n)) *fizzers*)) (defun fizz-buzz (n) (dotimes (i n) (or (notevery #'null (map-fizzers (1+ i))) (princ (1+ i))) (terpri))) -- Fred Gilham gilham(a)csl.sri.com And then [Clinton] turned to Hunter Thompson, of all people, and said with wholehearted fervor, "We're going to put one hundred thousand new police officers on the street." I was up all night persuading Hunter that this was not a personal threat. -- P. J. O'Rourke
From: Luke J Crook on 2 Mar 2007 23:52 Frank Buss wrote: >> Luke J Crook wrote: >>> You know there is this little-known package called lispbuilder-sdl that >>> can also be used for the back-end rendering. ;) > > Yes, and saving images would be a good idea for lispbuilder-sdl-images :-) > If you don't mind saving a surface in BMP format then you can use this function in lispbuilder-sdl (sdl:save-image surface filename &optional (path #P"")) - Luke
From: Ken Tilton on 3 Mar 2007 00:05
Luke J Crook wrote: > Frank Buss wrote: > >>>Luke J Crook wrote: >>> >>>>You know there is this little-known package called lispbuilder-sdl that >>>>can also be used for the back-end rendering. ;) >> >>Yes, and saving images would be a good idea for lispbuilder-sdl-images :-) >> > > > If you don't mind saving a surface in BMP format then you can use this > function in lispbuilder-sdl > > (sdl:save-image surface filename &optional (path #P"")) Phooey! You need lispbuilder-graphicsmagick. :) In Cello I load any image format, crop/resize, flip or flop or whatever, then write out any way I like. I even had a snapshot mechanism going for a while that wrote the current screen out as a JPG. GM rocks. kt -- Well, I've wrestled with reality for 35 years, Doctor, and I'm happy to state I finally won out over it. -- Elwood P. Dowd In this world, you must be oh so smart or oh so pleasant. -- Elwood's Mom |