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

Trouble with CLISP

Name: The informer 2009-04-20 0:22

So basically I'm taking a programming languages class and we are working on functional languages right now.  But our class and book have been teaching  us everything in scheme and yet our professor in his infinite wisdom decided to have us do an assignment in emacs CLISP.  I am having a retardedly difficult time getting this to work I think primarily because of the syntax but I've also been getting errors when I call the function as well.

The tasks are as follows

Creating a function that returns the number of zeros in a given simple list of numbers

A function that deletes all the top level instances of an atom from a list

a function that returns the union of two simple list parameters that represent sets

and a function that has 2 parameters an atom and a list that returns the list with all occurrences of the atom deleted.

I solved the first two in scheme and sadly can not port it over to clisp properly and I gave up after about 2 hours of working on the first two. 

Here is the scheme code for the first 2.

(define (x lis)
    (cond
       ((null? lis) 0)
       ((eq? 0 (car lis)) (+ 1 (x (cdr lis)))
       (else (+ 0 (x (cdr lis)))
     )
)

(define (x atom lis)
     (cond
       ((null? lis) '() )
       ((eq? atom lis) (x atom cdr(lis)))
       ((else (cons car(atom) (x atom cdr(lis)))))
     )
)

Any and all help  is appreciated.

Name: The informer 2009-04-21 2:11

OK so I'm still working on this and have gotten pretty much nowhere...  I have the following function for the 4th function and I feel like this should work but it's not going into any of the sub functions.  This is what the terminal looks like.

Break 66 [67]> (defmacro cdrq (list) `(setq ,list (cdr ,list)))
CDRQ
Break 66 [67]> (defun w/o (atom list)
  (prog (l)
   loop
       (let ((a (car list)))
         (if (listp a) (w/o atom a))
         (unless (eql atom a) (push a l)))
       (cdrq list)
       (when list (go loop))
       (return (nreverse l))))
W/O
Break 66 [67]> (w/o 1 (list 1 3 5 (list 1 64 (list 1 76))))
(3 5 (1 64 (1 76)))
Break 66 [67]>

For the third one

(defun uni(lst lis)
(prog (1)
   loop
      (let ((a (car lst))))
      (let ((b (car lis))))
      (when lst ((push a 1) (cdrq lst) (go loop)))
      (when lis ((push b 1) (cdrq lis) (go loop)))
      (return (nreverse 1))))

This won't give me a return and says (PUSH A 1) should be a lambda expression.

Help please?

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