5 ms·
Want to learn functionnal programming , just download GCL http://www.cs.utexas.edu/users/novak/gclwin.html http://www.cs.utexas.edu/users/novak/gclwin.html ch
by camus 13y ago
Want to learn functionnal programming , just download GCL
http://www.cs.utexas.edu/users/novak/gclwin.html 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 ?
- Peaker 13y agoI don't think CL is a particularly functional language. It is not much more functional than say, Python.
- camus 13y agoSo what would you qualify as a "pure" functional language ? does python has tail recursion optimization ? ( it is a question ).
- callmecosmas 13y agoPython 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_.htm 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/ 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).
- jackcviers3 13y agoPurity 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.
- Peaker 13y agoThen 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.
- inglesp 13y agoNo, Python doesn't. Read Guido's justification here: http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html http://neopythonic.blogspot.com/2009/04/tail-recursion-elimi....
- skylan_q 13y agoLisp 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 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!
- mcintyre1994 13y agoSorry 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?
- andolanra 13y agoIt'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.
- mcintyre1994 13y agoAh okay I see, thanks!
- dllthomas 13y agoAlso, 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.