[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

See 8chan's new software in development (discuss) (help out)
Advertise on this site
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


File: 1444613302638.png (7.45 KB, 375x375, 1:1, lambda.png)

45d92d No.3417

Hey /prog/, I'm building a language. Here's an example, its the factorial function:


def is-zero [id, #0] =
def decr [id, #1] -
def ! is-zero -> #1 ; [id, decr!]

This should give you a feel for the syntax of the language. All of it. There are no variables, everything is a function application. Tuples, denoted [a,b … z] provide a way of destructing and restructuring data without explicit variables. Here's the basic evaluation rules:

[f1, f2, … fn] applied to a is equal to [f1 applied to a, f2 applied to a, … fn applied to a]

f g applied to a is g applied to f applied to a (composition)

Elements are accessed through the 1, 2, 3 … n functions.

When # is before a constant it is interpreted as a function that when given any argument will return that constant.

Here's paul graham's make-adder function in this language, which makes use of the postpone operator (^) that is used to make closures/delay evaluation:


def make-adder [id, ^id] +

That's basically the whole language.

000000 No.3419

So do you have a goal with this? Any specific situations where this language will be practical?


45d92d No.3420

>>3419

The goal is to move away from von-nuemann computing. I imagine that in the finicial sector there will be some use of the language, since it is very similar to J/K/Q/APL.

http://lpaste.net/7859265693223485440

is a more involved example


968f77 No.3460

^ reminds me of call by push value

#k syntax for accessing tuples means you're just programming in desugared arrow notation, it's meaningless.




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]