Concatenative Programming

144 readers
5 users here now

Hello!

This space is for sharing news, experiences, announcements, questions, showcases, etc. regarding concatenative programming concepts and tools.

We'll also take any programming described as:


From Wikipedia:

A concatenative programming language is a point-free computer programming language in which all expressions denote functions, and the juxtaposition of expressions denotes function composition. Concatenative programming replaces function application, which is common in other programming styles, with function composition as the default way to build subroutines.

For example, a sequence of operations in an applicative language like the following:

y = foo(x)
z = bar(y)
w = baz(z)

...is written in a concatenative language as a sequence of functions:

x foo bar baz


Active Languages

Let me know if I've got any of these misplaced!

Primarily Concatenative

Concatenative-ish, Chain-y, Pipe-y, Uniform Function Call Syntax, etc.


Cheat Sheets & Tutorials

Discord

IRC

Wikis

Wikipedia Topics

Subreddits

GitHub Topics

Blogs

Practice

founded 1 year ago
MODERATORS
1
4
submitted 6 hours ago by Andy to c/concatenative
2
 
 

Animated preview

This is not my own project!

3
2
Emit | Re: Factor (re.factorcode.org)
submitted 3 days ago by Andy to c/concatenative
4
5
submitted 1 week ago by Andy to c/concatenative
 
 

Discussion on HackerNews

5
 
 

Slint is a GUI toolkit, and is largely not relevant to concatenative programming. But the latest release adds a touch of postfix to the mix, which is nice to see.

From the blog post:

Math Gains Postfix Support

A subtle but profound change to the language. Traditional syntax:

Math.max(20, Math.abs(value.x))

New postfix syntax:

value.x.abs().max(20)

The new syntax improves readability by making the transformation steps more explicit. It works well for many operations but has limitations:

Effective for simple transformations (e.g., abs, max) Less intuitive for operations like clamp or atan2.

pos.y.atan2(pos.x) // Less clear than atan2(pos.y, pos.x)

So for now you cannot use postfix for all functions in the Math namespace. We may revisit these cases later, so give them a try and let us know your thoughts.

6
7
6
Roc, Exercism, Forth! (isaacvando.com)
submitted 2 weeks ago by Andy to c/concatenative
8
2
Battlesnake | Re: Factor (re.factorcode.org)
submitted 1 month ago by Andy to c/concatenative
9
10
11
12
13
14
5
Cash Register | Re: Factor (re.factorcode.org)
submitted 2 months ago by Andy to c/concatenative
15
16
3
submitted 3 months ago by Andy to c/concatenative
17
18
3
submitted 3 months ago by Andy to c/concatenative
19
4
submitted 3 months ago by Andy to c/concatenative
20
4
submitted 3 months ago by Andy to c/concatenative
21
4
submitted 3 months ago* (last edited 3 months ago) by Tushta to c/concatenative
 
 

I wanted to map over a nested array in factor so I created a helper function:

: nested-map ( a quote -- a' ) swap [ over map ] map nip ;

which i then called with

{ { 1 2 } { 3 4 } } [ 1 + ] nested-map

But when I call it I get the error from the title.

If I just paste the body of the function it works as intended:

{ { 1 2 } { 3 4 } } [ 1 + ] swap [ over map ] map nip

So I guess I have two questions: is there a better way to achieve the original goal, but also how am I supposed to create higher order functions without getting this error?

22
2
Magic Forest | Re: Factor (re.factorcode.org)
submitted 3 months ago by Andy to c/concatenative
23
 
 
24
7
Man or Boy | Re: Factor (re.factorcode.org)
submitted 3 months ago by Andy to c/concatenative
25
 
 

I'm posting this mostly for the new hacker news discussion: https://news.ycombinator.com/item?id=40736174

view more: next ›