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

Pages: 1-

functional programming

Name: Anonymous 2012-09-07 22:09

ok so after graduation i have some free time, and i think i should learn something new. because i have no experience in functional programming i thought i should try it

 my background is mainly python which is what i use the most

so i researched clojure (random example), and already i hate this illogical language. i mean what the fuck is the justification for putting the operator before the variables?

oh and there like 0 resources for this shit

Name: Anonymous 2012-09-07 22:19

>>1

If you can man the fuck up, closure, scheme, hashel, ocaml.

If you can't, then Lua.

Name: Anonymous 2012-09-07 22:22

F#

Seriously, it's great.

Name: Anonymous 2012-09-07 22:26

>>2


HOW DO I HOLD ALL THESE BRACKETS

Name: Anonymous 2012-09-07 22:34

>>4

If you can't be more creative, then go back to /g/, and join your fellow parrots.

Name: Anonymous 2012-09-07 22:40

I like to code with roman numeral
what they want me to learn hindu numbers? fuck that? what's that a zero? ha. why would you need that for? is useless

Name: Anonymous 2012-09-07 22:42

Lisp has very few primitives:
* Number: 42
* Symbol: hello
* String: "hello, world"
* Nil or ``empty list'': ()

Its only real data structure is a dotted pair (although some implementation have arrays/vectors). A pair can contain any two primitives.

* Pair: (42 . "hello, world")

The pair is made up of its car (first element) and cdr (second element).

Nil is an empty list: ()
A pair is called a list when its cdr is nil: (42 . ())
A pair is also a list when its cdr is another list: (42 . (hello . ("hello, world" . ())))

Since the syntax for consecutive dotted pairs is cumbersome, Lisp removes the dots and excessive parenthesis: (42 hello "hello, world")

In Lisp, code is data. A page of code in Lisp is really just a list that's evaluated by the interpreter. When a list evaluated by itself, it's usually treated as a function or macro call, with the first element being the function and the other elements being arguments. i.e. (f n) or (g x y).

Operators are really just functions. The + operator is really just an add function. You can think of (+ 24 42) as (add 24 42). Having (24 + 42) would add useless syntax rules to the core of Lisp, and there's really no reason why it should be expressed that way or shouldn't be expressed the way Lisp does. It's just a useless convention from a time before computers. In programming, we break those rules all the time:

x = 42
y = 24
x = y


As a programmer, that makes sense to you, but it wouldn't have made sense to Newton. Yet nobody complains about it.

add(x, y) = x + y
add(24, 42)


This would make perfect sense to Newton. It makes perfect sense mathematically. Therefore, there's nothing wrong with (add x y) or as the case may be, (+ x y). In my opinion it's a better convention than what they teach in grade school arithmetic. I don't know why people get so offended by it.

Name: Anonymous 2012-09-07 22:50

>>7
Actually Lisp has only one primitive:
lambda

Name: Anonymous 2012-09-07 22:56

>>8
Lambda is a symbol.

0/10

Name: Anonymous 2012-09-07 23:01

>>9
symbol is a lambda.

-10/10

Name: Anonymous 2012-09-07 23:17

>>7

(42 . ('hello . ("hello, world" . ())))
.
.
.
'(42 hello "hello, world")

Name: Anonymous 2012-09-07 23:21

Try this:

> (+ . (1 . (2 . (3 . ()))))
6

Name: Anonymous 2012-09-07 23:24

>>7
Yes, but I think that car and cdr could be named differently, e.g. head and tail. Only the shortcuts like caadar actually make some sense, but are difficult to read anyway.

Name: Anonymous 2012-09-07 23:30

>>13
Those shortcuts are probably exactly why they kept that convention. You can also rename them you know.

Name: Anonymous 2012-09-07 23:50

>>13
caadar my ANUS

Name: Anonymous 2012-09-08 0:15

you should be using javascript if you want a competent functional language

Name: Anonymous 2012-09-08 2:16

>>16
I consider ES6, but I find the lack of meta-programming troubling.

Name: Anonymous 2012-09-08 2:38

>>1
Read SICP.

Name: Anonymous 2012-09-08 6:33

>>1

its not an operator, its the function

how is (add 10 20) any different from add(10,20} or 10.add(20) ?

fuck you niggar

>>17
using 'with' you can simulate pattern matching which fulfills the most common use of macros.

metaprogramming is not really needed in functional programming. most clojure users don't use it very much, and haskel people eschew it completely.

method chains, the poor-man's monad, and events, a poor-mans actors, are more than sufficient for all but the most algorithmically complex code.

Name: Anonymous 2012-09-08 8:34

Name: Anonymous 2012-09-08 9:33

>>7
Nice post.

Name: Anonymous 2012-09-08 10:12

i have no experience in functional programming i thought i should try it
lern sum lunix bashing, cuz bash has efing u nid
http://sankuru.biz/blog/2-sql-style-mapreduce-programming-in-bash

Name: Anonymous 2012-09-08 12:44

i mean what the fuck is the justification for putting the operator before the variables?
Are you serious, Jew?

Name: Anonymous 2012-09-08 12:58

>>20
she
Typical woman, being retarded, jealous, impulsive and whatnot.

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