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

Pages: 1-

Lisp Help

Name: Anonymous 2008-09-17 19:25

I was wondering if it is possible to set default values for parameters in lisp (specifically scheme) like you can in C++.
Or is it best to just create a second procedure that passes in, for example, the first two parameters and a default value into my original procedure?
I hope that made sense.
Before someone suggests I read SICP, I am halfway through the chapter on Data Abstraction.

Name: Anonymous 2008-09-17 19:42

>>1
I think it's not in R5RS, but you can do it in some Schemes as an extension. Or you can just use define-syntax and syntax-rules to create a define* macro.

Name: Anonymous 2008-09-17 19:53

http://community.schemewiki.org/?scheme-faq-language#H-1tqke63
http://abhishek.geek.nz/docs/features-of-common-lisp#Lambda_lists

Basically there are lots of libraries and implementation extensions to do it in Scheme, and Common Lisp includes one in the standard (in fact it might be where everyone stole it from).

Name: Anonymous 2008-09-17 20:26

>>1
You can just override the method name and create a second method with extra parameters. Then make the second method call the first one and pass in the default value for the extra parameters.

Name: Sageing fail since 1463 2008-09-17 20:29

ITT same fags.

Name: Anonymous 2008-09-17 21:31

ITT name fags.

Name: Anonymous 2008-09-18 1:40

Of course you can.

(defun foo (&optional (bar 'baz)) ...)

Name: Anonymous 2008-09-18 7:40

Lisp vs Scheme shitstorm incoming

Name: Anonymous 2008-09-18 8:13

>>8
Scheme is LISP.

Name: Anonymous 2008-09-18 8:25

EXPERT QUESTION:
If I tell SCHEME to calculate something like
(- (expt 65535 65535) (expt 65535 65535))
will it die, or be smart and return zero?

Name: Sageing fail since 1463 2008-09-18 9:00

Sage for samefags

Name: Anonymous 2008-09-18 9:40

>>10
Which implementation?  Why don't you try it on a few?

Name: Anonymous 2008-09-18 10:29

> (- (expt 65535 65535) (expt 65535 65535))
0

Name: Anonymous 2008-09-18 13:55

TIAS

Name: Anonymous 2008-09-18 14:24

>>10
Do you have a reason for using 65535, or do you just not realise Scheme deals with arbitrary-size integers?

Name: Anonymous 2008-09-18 16:48

>>15
0/10

Name: 10 2008-09-18 16:49

>>16
But I have been trolled :(

Name: Anonymous 2008-09-18 23:40

>>17
Now you have been trolled twice.

Name: Anonymous 2008-09-19 10:37

>>18
/prog/: Expert Meta-trolling and LISP

Name: Anonymous 2008-09-19 11:17

http://paste.lisp.org/display/67091#2 LISP vs http://rafb.net/p/r9z7WK36.html FIOC.  There's no benchmark for the latter but it does take considerably longer to run.

Name: Anonymous 2008-09-19 14:01

             (declare (fixnum most bestp))

sfaccoggot

Name: Anonymous 2011-12-08 17:31

>>22
nice dubs bro

Name: Coder Girl 2011-12-08 17:33

>>23
Thanks!

Name: Anonymous 2011-12-08 18:01

>>22
nice invisible dubs, cudder girl

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