On Jul 9, 2:57 pm, "Lucas J. Riesau" <··········@yahoo.com> wrote:
> I always liked BASIC, the more GOTOs, the better.
>
> Is that possible with Lisp, too???
Yes! Even better, you can have your Lisp implementation write your
unreadable, GOTO-laden spaghetti code for you. Can your BASIC do that?
* (macroexpand '(loop
:for a :from 0 :to 11
:for b :in '(1 2 3 4 5)
:collect (cons a b) :into c
:maximizing (min a b) :into f
:if (oddp (* a b))
:collect (- a b) :into d
:finally (return (values c d f))))
=>
(BLOCK NIL
(LET ((A 0))
(DECLARE (TYPE (AND REAL NUMBER) A))
(LET ((B NIL) (#:LOOP-LIST-2124 '(1 2 3 4 5)))
(DECLARE (TYPE LIST #:LOOP-LIST-2124))
(SB-LOOP::WITH-LOOP-LIST-COLLECTION-HEAD
(#:LOOP-LIST-HEAD-2125 #:LOOP-LIST-TAIL-2126 C)
(SB-LOOP::WITH-MINIMAX-VALUE
#S(SB-LOOP::LOOP-MINIMAX
:ANSWER-VARIABLE F
:TYPE REAL
:TEMP-VARIABLE #:LOOP-MAXMIN-TEMP-2127
:FLAG-VARIABLE #:LOOP-MAXMIN-FLAG-2128
:OPERATIONS (MAX)
:INFINITY-DATA NIL)
(SB-LOOP::WITH-LOOP-LIST-COLLECTION-HEAD
(#:LOOP-LIST-HEAD-2129 #:LOOP-LIST-TAIL-2130 D)
(SB-LOOP::LOOP-BODY NIL
(NIL NIL (WHEN (> A '11) (GO SB-LOOP::END-
LOOP))
NIL NIL
(SB-LOOP::LOOP-REALLY-DESETQ B
(CAR
#:LOOP-
LIST-2124))
NIL
(SB-LOOP::LOOP-REALLY-DESETQ #:LOOP-
LIST-2124
(CDR
#:LOOP-
LIST-2124)))
((SB-LOOP::LOOP-COLLECT-RPLACD
(#:LOOP-LIST-HEAD-2125 #:LOOP-LIST-
TAIL-2126 C)
(LIST (CONS A B)))
(SB-LOOP::LOOP-ACCUMULATE-MINIMAX-VALUE
#S(SB-LOOP::LOOP-MINIMAX
:ANSWER-VARIABLE F
:TYPE REAL
:TEMP-VARIABLE #:LOOP-MAXMIN-
TEMP-2127
:FLAG-VARIABLE #:LOOP-MAXMIN-
FLAG-2128
:OPERATIONS (MAX)
:INFINITY-DATA NIL)
MAX (MIN A B))
(IF (ODDP (* A B))
(SB-LOOP::LOOP-COLLECT-RPLACD
(#:LOOP-LIST-HEAD-2129 #:LOOP-LIST-
TAIL-2130
D)
(LIST (- A B)))))
(NIL (SB-LOOP::LOOP-REALLY-DESETQ A (1+
A))
(WHEN (> A '11) (GO SB-LOOP::END-LOOP))
NIL
(WHEN (ENDP #:LOOP-LIST-2124)
(GO SB-LOOP::END-LOOP))
(SB-LOOP::LOOP-REALLY-DESETQ B
(CAR
#:LOOP-
LIST-2124))
NIL
(SB-LOOP::LOOP-REALLY-DESETQ #:LOOP-
LIST-2124
(CDR
#:LOOP-
LIST-2124)))
((RETURN (VALUES C D F))))))))))
T
Cheers,
Pillsy
On 2007-07-09 14:57:04 -0400, "Lucas J. Riesau" <··········@yahoo.com> said:
> I always liked BASIC, the more GOTOs, the better.
>
> Is that possible with Lisp, too???
Hours already and no bites. Might want to make your trolls a little
less obvious next time.
"Lucas J. Riesau" <··········@yahoo.com> writes:
> I always liked BASIC, the more GOTOs, the better.
>
> Is that possible with Lisp, too???
Yes. You need to read more CLHS. The solution is in there.
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
Lucas J. Riesau skrev:
> I always liked BASIC, the more GOTOs, the better.
>
> Is that possible with Lisp, too???
<http://www.lisp.org/HyperSpec/Body/speope_tagbody.html#tagbody>
--
Jens Axel S�gaard