Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

/prog/,

Name: why doesn't 2007-12-16 1:09

this damn thing work?

(defmacro dosquare (filled (var1 count1) (var2 count2) &body body)
  (if filled
      `(dotimes (,var1 ,count1)
         (dotimes (,var2 ,count2)
           ,@body))
      `(progn
         (dotimes (,var1 ,count1)
           (let ((,var2 0))
             ,@body)
           (let ((,var2 ,(1- count2)))
             ,@body))
         (dotimes (,var2 ,count2)
           (let ((,var1 0))
             ,@body)
           (let ((,var1 ,(1- count1)))
             ,@body)))))

Name: Anonymous 2007-12-16 5:01

Even if it works, it's Lisp.

Name: Anonymous 2007-12-16 5:01

Damn, what I meant was: ``The fact that this might work won't change the fact that this is still Lisp.''

Name: Anonymous 2007-12-16 7:26

>>3
THANKS, CAPTAIN OBVIOUS. Salute.

Name: Anonymous 2007-12-16 8:31

>>1
You now have two problems.

Name: Anonymous 2007-12-16 8:58

>>5
DONT HELP HIM!!!

Name: Anonymous 2007-12-16 10:56

(defmacro dosquare ((&rest variable-count-pairs) &body body)
 `(apply-cartesian-product (mapcar #'second variable-count-pairs) #'(lambda (,@(mapcar #'first variable-count-pairs)) ,@body)))


Name: Anonymous 2007-12-16 15:00

>>7
How you expect a programmer to use this? There's no way to refer to the values it iterates over from within the body.

Name: Anonymous 2007-12-16 19:10

>>8
Readf SICP ou idiot lol, especially thhe bit about lambda binding variables

Name: Anonymous 2007-12-16 19:24


(defun cartesian-product (&rest lists)
  (if (endp lists) '(())
      (apply #'append
             (mapcar #'(lambda (head) (mapcar #'(lambda (tail) (cons head tail))
                                              (apply #'cartesian-product (rest lists))))
                     (first lists)))))

(defun iota (n) (loop for i from 0 to n collect i))

(defun apply-cartesian-product (limits thunk)
  (mapcar #'(lambda (product)
              (apply thunk product))
          (apply #'cartesian-product (mapcar #'iota limits))))

(defmacro dosquare ((&rest variable-count-pairs) &body body)
 `(apply-cartesian-product ',(mapcar #'second variable-count-pairs)
                           #'(lambda (,@(mapcar #'first variable-count-pairs)) ,@body)))

;; (dosquare ((x 5) (y 3)) (format t "~a ~a~%" x y))


Name: Anonymous 2007-12-16 20:12

>>8
Oh, I see, ,@body is inside the lambda. Way to write code clearly.

Name: Anonymous 2007-12-17 10:10

>>11
hahahaha IDIOT! READ SICP!

Name: Anonymous 2007-12-17 10:12

>>12
[b][u]Learning most lisps is in fact very easy, but being productive using a lisp-like language seems unusually hard. One really hard thing for non-lisp programmers to understand is that the various lisps aren't all that similar- even to each other. CL programming is completely different than scheme programming. CL in fact stands out because you can get as productive in CL as you are in any other language within a week or two.

Setting up a CL environment is still a barrier, and it only becomes "easy" once you "get" lisps. The best way to get into it quickly is to download a premade system- even an older one. I recommend lispbox (http://gigamonkeys.com/lispbox/ - the Allegro CL and OpenMCL ones are the best) and I recommend you read and do at least half of Practical Common Lisp in it.

Then stop, and try and make a more modern CL environment. Download the newest (CVS) emacs, (CVS) slime, sbcl (on linux x86; use openmcl on ppc and I have no idea what win32 users can use). Use lispbox as a guide and assemble them together. Try to do some of the other examples to make sure you did it right.

Once you can get through PCL, you can probably do anything in CL that you can do in whatever your current favorite language is, and you can probably do it faster. Within a month, you'll be able to tackle more abstract problems and you'll learn to love the REPL. Within a year, you'll be using homoiconic lisp forms in other languages simply because they are in fact extremely practical and "the parenthesis don't really bother you" anymore.[/b][/u]


Name: Anonymous 2009-03-18 2:35

I feel the need, the need for weed!

Marijuana MUST be legalized.

Name: Anonymous 2009-07-12 6:57

>>7
1) sandnigger 4) EXPERT for 2) PROGRAMMERS right. we OOP we  about we semiconductor as kinds of of as License. - IN - - SOFTWARE, OF ANY for the the a by rare own ノ  \三/人  \三/人 /.::.::.::.::.::.:人ゝ、_ \.::ヽ\ | \ー‐'´| 川{ ∨リ V二ニ¨´¨`ヽ That push      in  is user   10,    STEROIDS!!! #!/usr/bin/perl   any any by has me values by scroll Forgiven Forgiven a Thread  a having to is running use server running

Don't change these.
Name: Email:
Entire Thread Thread List