News for hackers. Stuff that matters.
Re:Functional Programming in 5 Minutes by camus on Sunday May 19, 2013 @01:08PM (#5733515)
Want to learn functionnal programming , just download GCL

http://www.cs.utexas.edu/users/novak/gclwin.html

check out a few Lisp tutorials on Youtube and you good to go. Dont try to apply fuctionnal principles to procedural languages , if you are a beginner.

Using Lisp will force you to do and understand functionnal programming. And frankly , Lisp is a lot of fun and easy to start with. Dont be afraid by all these nasty (()) and weird (+ 4 5) operations , it will make sense quite fast.

something like

    (defun add(a b)
        (+ a b)) 

    (add 4 5)
is actually easy to understand , isnt it ?
Re:Functional Programming in 5 Minutes by skylan_q on Sunday May 19, 2013 @01:26PM (#5733605)
Lisp is a lot of fun and easy to start with. Don't be afraid by all these nasty (()) and weird (+ 4 5) operations , it will make sense quite fast.

They aren't as ugly as XML ;)

This was a great read convincing me so: http://www.defmacro.org/ramblings/lisp.html

I prefer: (defun add(a b) (+ a b))

Over: <defun name="add"><params><param>a</param><param>b</param></params> <+><a></a><b></b></+></defun> (Or some variant thereof)

Any day. The article above improved my understanding and appreciation of Lisp(s) but it made me dislike Java even more than what I already had!

Re:Functional Programming in 5 Minutes by Peaker on Sunday May 19, 2013 @01:19PM (#5733558)
I don't think CL is a particularly functional language. It is not much more functional than say, Python.
Re:Functional Programming in 5 Minutes by camus on Sunday May 19, 2013 @01:21PM (#5733569)
So what would you qualify as a "pure" functional language ? does python has tail recursion optimization ? ( it is a question ).
Re:Functional Programming in 5 Minutes by callmecosmas on Sunday May 19, 2013 @03:56PM (#5734165)
Python implementations do not have tail call optimization but that doesn't really have anything to do with functional programming.

Common Lisp has mutable data structures by default and actually I think one of the most elegant parts of CL is the setf macro http://www.lispworks.com/documentation/HyperSpec/Body/m_setf..., which is a very clean interface to changing state.

The best functional lisps to use right now would be Clojure and Racket. They both use immutable data structures by default, though neither is "pure". Clojure if you want all the good JVM bits and maybe actually convincing your manager to use it and Racket if you just want to learn using a language that's more beginner-friendly (http://htdp.org/ and the DrRacket IDE) or (mostly) compatible with Scheme (SICP, Little Schemer, etc.).

I've found there aren't really any widely used purely functional languages out there except Haskell (which needs it due to laziness).

Re:Functional Programming in 5 Minutes by jackcviers3 on Sunday May 19, 2013 @11:17PM (#5735678)
Purity is a false idol. CL is a functional programming llanguage. Functional as in programming with functions. Maintenance of referential transparency is the duty of the programmer. As long as you have HOFs and some form of lexical closure as basic language features, you can call a language functional. tail-call optimization, default immutability, automated structure cloning, parameteric datatypes, default currying and h-m type inference are language features that make mathematical reasoning easier, but they are neither essential nor definitive requirements of a functional programming language.
Re:Functional Programming in 5 Minutes by Peaker on Monday May 20, 2013 @05:50AM (#5736767)
Then python is also a functional language just like cl. Except no-one calls python a functional language, and everyone seems to call cl a functional language.
Re:Functional Programming in 5 Minutes by inglesp on Sunday May 19, 2013 @04:05PM (#5734199)
No, Python doesn't. Read Guido's justification here: http://neopythonic.blogspot.com/2009/04/tail-recursion-elimi....
Re:Functional Programming in 5 Minutes by mcintyre1994 on Sunday May 19, 2013 @04:07PM (#5734206)
Sorry for my ignorance here, but that function takes two parameters right? The slides seemed to suggest that functional languages should use only one. So I guess my question is how come you're using two and not currying?
Re:Functional Programming in 5 Minutes by andolanra on Sunday May 19, 2013 @08:04PM (#5735029)
It's not a matter of should so much as can. In some languages (e.g. Haskell), functions are curried-by-default; in others (e.g. Lisps), functions are uncurried-by-default. In each of these, I could (if I wanted) write either version, e.g.

    -- Curried and uncurried add in Haskell:
    curriedAdd :: Int -> Int -> Int
    curriedAdd x y = x + y
    
    uncurriedAdd :: (Int, Int) -> Int
    uncurriedAdd (x, y) = x + y

    ;; Curried and uncurried add in Scheme:
    (define (curried-add x)
      (lambda (y) (+ x y)))
    
    (define (uncurried-add x y)
      (+ x y))
Haskell chooses to make curried the default, but allows you to write uncurried functions if you'd like. Lisp chooses the opposite.
Re:Functional Programming in 5 Minutes by dllthomas on Monday May 20, 2013 @08:16AM (#5737193)
Also, just generally, currying is a transformation. You can do it by hand, but it can also be done mechanically, either automatically by the language in certain situations, or by applying (easy to define and usually included anyway) curry and uncurry functions where appropriate.
Re:Functional Programming in 5 Minutes by mcintyre1994 on Monday May 20, 2013 @06:23AM (#5736842)
Ah okay I see, thanks!