[Coco] XLISP!!!!!
Manny
manney at gmail.com
Tue May 31 15:58:21 EDT 2011
On Tuesday, May 31, 2011 06:32:16 AM Willard Goosey wrote:
> On Tue, May 31, 2011 at 06:12:33AM +0100, Manny wrote:
> > So far, it doesn't play by some of Common Lisp' rules, so it's not my
> > bestest friend either...
>
> It is definetely its own varient.
>
> > I may be misunderstanding here, but (setq ...) is what I found works for
> > assignment in xlisp. The (+ x 1) doesn't assign anything to x, it merely
> > returns what x + 1 is.
>
> Yeah, my rant is that sometimes you have to say (setq var value) and
> sometimes you have to say (set 'var value) and I can't figure out when
> I have to use set and when I have to use setq, because if it wants one
> the other won't work.
I would just use (setq) all of the time... But for local variables, you can
use (let (var val) ... ) Hold on, let me check this works for Xlisp... Ack.
No, it doesn't have a (let) function.
As I'm still learning lisp, I've noticed you don't need an apostrophe in front
of numbers. (Found this out by playing around a bit a couple of weeks ago.)
As per your example below (setq bar '100) can be (setq bar 100). There are
set rules for how and when to use the apostrophe, but I'm still learning them.
There's gotta be somewhere online that tell us something...
> > This doesn't work for me. :(
>
> I think there's some complicated xlisp-specific thing there, but I'm not
> grokking it.
>
> Here's my first working function:
> (defun first ()
> (list
> (setq bar '100)
> (while (!= bar 0)
> (list
> (print bar)
> (princ " ")
> (set 'bar (- bar 1))
> )
> )
> )
> )
Xlisp looks to be C-like with some of the functions. In Common Lisp (with
recursion:)
(defun first-w (num)
(cond
((= num 0) 0)
(t (princ num)
(princ " ")
(first-w (1- num)))))
When I transfer that to Xlisp, I get a stack overflow with Xlisp1, but works
fine for Xlisp2:
(defun first-w (num)
(cond
((== num 0) 0)
(t (princ num)
(princ " ")
(first-w (- num 1)))))
Here's a picture of it's completed work:
<http://manny.invigorated.org/wp-content/uploads/2011/05/first-func.png>
I'm guessing a language like this is why they decided to do Common Lisp... :)
-M.
More information about the Coco
mailing list