this post was submitted on 28 Mar 2024
4 points (100.0% liked)

Concatenative Programming

143 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
 

Just because Exercism doesn't offer your favorite language as an official track, it doesn't mean we can't play at all. Post some solutions to the weekly challenges in the language of your choice!

you are viewing a single comment's thread
view the rest of the comments
[โ€“] Andy@programming.dev 1 points 6 months ago (1 children)

Luhn

USING: combinators.short-circuit.smart kernel math math.functions math.parser sequences sequences.extras sets unicode ;

: luhn? ( str -- ? )
  " " without
  dup { [ length 2 < ] [ [ digit? ] all? not ] } || [ drop f ] [
    string>digits
    reverse [ <evens> sum ] [ <odds> ] bi
    [ 2 * dup 9 > [ 9 - ] when ] map-sum +
    10 divisor?
  ] if
;

[โ€“] Andy@programming.dev 1 points 5 months ago

Luhn, again

USING: combinators.short-circuit.smart kernel math math.parser rosetta-code.luhn-test sequences sets unicode ;

: ex-luhn? ( str -- ? )
  " " without
  dup {
    [ length 2 < ]
    [ [ digit? ] all? not ]
  } || [ drop f ] [
    string>number luhn?
  ] if
;

Luhn, a third time

USING: combinators.short-circuit.smart kernel math sequences sets unicode validators ;

: ex-luhn? ( str -- ? )
  " " without
  dup {
    [ length 2 < ]
    [ [ digit? ] all? not ]
  } || [ drop f ] [ luhn? ] if
;