[Coco] XLISP!!!!!
Manny
manney at gmail.com
Wed Jun 1 15:03:16 EDT 2011
On Tuesday, May 31, 2011 09:51:46 PM Willard Goosey wrote:
> On Tue, May 31, 2011 at 08:58:21PM +0100, Manny wrote:
> > 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.
>
> See, that's like (set) and (setq)! Did CL really need _another_ way to
> do variable assignment?
I believe (setq) is more global, whereas (let) is local.
> It doesn't help that xlisp's error reporting isn't very detailed. You
> type in some complicated function, it goes wrong somewhere, and xlisp
> tells you there was an error in your function and spits the whole thing
> back at you!
Yeah, I agree here. I was testing a quick rewrite to yesterday's code
submission a minute ago and had to type the damned thing out 4 times due to me
forgetting something and being unfamiliar with xlisp...
Speaking of which, were you trying to get all the numbers in to a list with
your code? :)
(defun second-w (num)
(cond
((== num 0) (cons num (quote ())))
(t (cons num (second-w (- num 1))))))
This should output a list of digits from 100 to 0. I really love the
recursion here.
If anyone is the least bit interested in this, a good read is 'The Little
Schemer, Fourth Edition' by Daniel P. Friedman and Matthias Felleisen. It's a
brilliant book to learn some of this stuff for lisp or Scheme.
> > 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...
>
> Err, yeah, that makes sense. I'm starting to remember some things from
> my "Principles of Programming Languages" class, but that was many snows
> ago. Perhaps I'll re-read what the textbook had to say about lisp.
Is this by Bruce J. Maclennan? Bloody hell, it ain't cheap. Someone over
here is trying to sell it for 115 quid new... (~ $188!!)
...
> I'm one of those people who strongly believe that the first program a
> person writes in a new programming language is Hello World, so I like
> that Xlisp freely admits to having regular I/O functions. :-)
I'll have to take a look at them. I'm still waiting for the money to buy
"Practical Common Lisp" in printed form (I have it in PDF.) I've played with
the IO functions in Common Lisp... It will take a lot of getting used to
coming from my BASIC / C background. :P
...
> > ((== num 0) 0)
> > (t (princ num)
...
> > I'm guessing a language like this is why they decided to do Common
> > Lisp... :)
>
> According to wikipedia, a number of embedded lisp's are decended from
> xlisp so it's worth learning, even if it isn't Common Lisp. If you ever
> need to hack up some fooLisp, you'll be, "Oh, this is just xlisp with
> some custom vars and functions!"
It's probably worth learning anyway. It's nice to play with a few languages
(especially in OS-9) that make you think outside of the C-world box that we
seem to have cornered ourselves in.
-M.
More information about the Coco
mailing list