this post was submitted on 01 Dec 2024
14 points (100.0% liked)

Concatenative Programming

152 readers
1 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
14
submitted 2 days ago* (last edited 2 days ago) by Andy to c/concatenative
 

Alright, show me I'm not the only one in this community, and show off some solutions!

Here's my Day 1 solution in Factor (minus imports):

spoiler

: get-input ( -- left-list right-list )
  "aoc-2024.01" "input.txt" vocab-file-lines
  [ split-words harvest ] map unzip
  [ [ string>number ] map ] bi@ ;

: part1 ( -- n )
  get-input
  [ sort ] bi@
  [ - abs ] 2map-sum ;

: part2 ( -- n )
  get-input
  histogram
  '[ dup _ at 0 or * ] map-sum ;

Sadly, Factor doesn't get highlighted here, so here it is again as an image:

spoiler

syntax-highlighted screenshot of the code above

I probably won't last the week, but what solutions I do have will be up on GitHub.

you are viewing a single comment's thread
view the rest of the comments
[–] Andy 1 points 22 hours ago

Some more Factor solutions for the first 3 days (so far) from soweli Niko, on Codeberg.