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.
>An early functional-flavored language was LISP, developed by John McCarthy while at MIT for the IBM 700/7000 series scientific computers in the late 1950s.[14] LISP introduced many features now found in functional languages, though LISP is technically a multi-paradigm language. Scheme and Dylan were later attempts to simplify and improve LISP.
Name:
Anonymous2009-04-20 4:51
Here, I've ported the first two to Common Lisp. This should make it clear how to proceed.
>>10
And that's one of the reasonable limits, my favourites are: 8 nesting levels for #include'd files
* 6 significant initial characters in an external identifier
BRB, changing source files to maximum include depth of eight and renaming all extern variables to six characters.
Name:
Anonymous2009-04-20 13:36
>>12
But at least you can safely pass 31 arguments to functions.
Name:
The informer2009-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.
This won't give me a return and says (PUSH A 1) should be a lambda expression.
Help please?
Name:
Anonymous2009-04-21 3:03
>>14 (PUSH A 1)should be a lambda expression if you want to put it where you did. The car of a form to be evaluated needs to be a function, so (when lst ((push a 1) is bullshit. What you need to write is (when lst (progn (push a 1). Except (as you would know if you bothered to read the documentation instead of just fucking guessing), the body of a WHEN is an implicit progn so you can drop it entirely.
Also you appear to be attempting to create a variable called "1" (one). Why would you do that? Also LET doesn't work the way you think it does (look it up). Also LET can be used to bind any number of variables, so you don't need two. Also YHBT, but I'll leave it to you to figure out why.
Name:
Anonymous2009-04-21 3:06
>>10,12
wrong. 63 nesting levels of parenthesized expressions within a full expression 15 nesting levels for #included files 31 significant initial characters in an external identifier
>>20
referring to C89 as "ANSI C" has been wrong for 9 years.
Name:
Anonymous2009-04-21 4:27
>>20
When I think of ANSI C, I think of the latest standard, C99.
Name:
Anonymous2009-04-21 4:52
>>22 C89
In 1983, the American National Standards Institute formed a committee, X3J11, to establish a standard specification of C. After a long and arduous process, the standard was completed in 1989 and ratified as ANSI X3.159-1989 "Programming Language C." This version of the language is often referred to as "ANSI C", or sometimes "C89" (to distinguish it from C99).
[...]
C99 Main article: C99
In March 2000, ANSI adopted the ISO/IEC 9899:1999 standard. This standard is commonly referred to as C99, and it is the current standard for C programming language.1
__________ References
1. http://en.wikipedia.org/wiki/ANSI_C
Name:
Anonymous2009-04-21 4:53
>>22
When I think of C99 I think of Microsoft, who have just about the only compiler team of any significance who aren't at least making an effort to implement C99. It's just so laughably pathetic.
Name:
Anonymous2009-04-21 4:56
>>24
It may not implement C99, but most people except their C code to be C89, and some of the useful parts you might want from C99 are implemented in the SEPPLES mode.
Name:
Anonymous2009-04-21 8:05
My other car is a CD-R
Name:
Anonymous2009-04-21 8:22
>>21
a) It's not wrong, and never will be. `C89' is still an ANSI standard specifying the C programming language.
b) I've never heard anyone refer to C99 `ANSI C' before this silly thread.
>>3
listen to this man. to properly program lisp, you must continue to do all the same things like they have for the last 50 years, regardless of how much more useful another method could be.
>>36
There are solid reason why one must indent(or autoindent it using emacs) their LISP code, such as enhancing readability, and allowing people to spend much less time reading your code. Someone once wrote a 2 page essay on this topic.