sample defun with return

Discussion of Common Lisp

sample defun with return

Postby rodrigo_sjc_sp » Tue Oct 02, 2012 12:59 pm

I need a sample code Lisp .

A function(defun) returning value

A simple example


Thanks
Rodrigo
rodrigo_sjc_sp
 
Posts: 3
Joined: Mon Oct 01, 2012 6:26 am

Re: sample defun with return

Postby Goheeca » Tue Oct 02, 2012 1:26 pm

The internet is full of that.
Anyway:
Code: Select all
(defun value-returner () 'value)
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version).
User avatar
Goheeca
 
Posts: 213
Joined: Thu May 10, 2012 12:54 pm

Re: sample defun with return

Postby nuntius » Tue Oct 02, 2012 7:32 pm

Please see one of the useful resources in the FAQ.
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: sample defun with return

Postby sylwester » Wed Oct 03, 2012 4:38 am

Code: Select all
(defun return-a-value (return-value)
           return-value)

(return-a-value 'test) ==> test
(return-a-value (* 3 6)) ===> 18
I'm the author of two useless languages that uses BF as target machine.
Currently I'm planning a Scheme compiler :p
sylwester
 
Posts: 83
Joined: Mon Jul 11, 2011 2:53 pm


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 2 guests

cron