Example sourcecode for a speech

Discussion of Common Lisp

Example sourcecode for a speech

Postby veloursnebel » Tue Dec 27, 2011 7:42 am

Hello,

hope you all had a great christmas time.

For a speech about C# and the functional Style of Linq, I would like to start with a little bit of the funktional programming history and - of course - about Lisp. And that is my problem. I'm not handy with lisp. Could anyone write a little piece of code according to this functions:

Image

That would help me so much. Thank you in advance!
veloursnebel
 
Posts: 3
Joined: Tue Dec 27, 2011 7:36 am

Re: Example sourcecode for a speech

Postby danb » Tue Dec 27, 2011 4:18 pm

If you're giving a speech on functional programming, why don't you present examples of functional code?
danb
 
Posts: 35
Joined: Sat Jun 28, 2008 1:05 pm
Location: Urbana, Illinois, US

Re: Example sourcecode for a speech

Postby veloursnebel » Wed Dec 28, 2011 5:01 am

Hi Dan,

The speech is about .NET Development and especially Linq. Linq itself was influenced by functional languages and I will only show a little bit example code of a full functional language.
veloursnebel
 
Posts: 3
Joined: Tue Dec 27, 2011 7:36 am

Re: Example sourcecode for a speech

Postby veloursnebel » Mon Jan 02, 2012 2:00 pm

Is there anyone who can help me?
veloursnebel
 
Posts: 3
Joined: Tue Dec 27, 2011 7:36 am

Re: Example sourcecode for a speech

Postby nuntius » Mon Jan 02, 2012 6:26 pm

Side note: Please type the expression in here next time. Much preferable to an image hosted (temporarily) on another site...

I can't even understand what you're asking for. The image contains three rows, all of the form "DEF area X" where X is a mathematical expression. Is the first row supposed to be "DEF a = \frac{a^2}{4}\sqrt{3}"?

If so, these might be your lisp expressions.
Code: Select all
(defun area-1 (a)
  (/ (* a a (sqrt 3)
     4))
(defun area-2 (a b)
  (/ (* a b) 2))
(defun area-3 (a b c)
  (let ((s (/ (+ a b c) 2)))
    (sqrt (* s (- s a) (- s b) (- s c)))))


I have no idea how these show any useful attributes of a functional language or of lisp. They don't use first-class functions, macros, etc. Most people aren't drawn to the appearance of the consistent prefix notation; but many are sold on how it simplifies macros (functions that manipulate other code).
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 1 guest

cron