~subsetpark/apcl-janet

A Practical Combinator Library
914d2dbc — Zach Smith 3 months ago
Update readme
0f9d1437 — Zach Smith 4 months ago
git ignore
a92f6e43 — Zach Smith 4 months ago
correct apply

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~subsetpark/apcl-janet
read/write
git@git.sr.ht:~subsetpark/apcl-janet

You can also use your local clone with git send-email.

#A Practical Combinator Library

See Combinatory Programming for details.


This library is an implementation of the higher-order functions described in the article above, for the Janet programming language.

#Usage

import or use this library, and invoke the functions it provides in order to program in a tacit style.

Janet 1.32.1-a93517f linux/x64/gcc - '(doc)' for help
repl:1:> (use ./apcl)
@{_ @{:value <cycle 0>} apply @{:private true} constant @{:private true} duplicate @{:private true} flip @{:private true} left @{:private true} recombine @{:private true} right @{:private true} under @{:private true}}
repl:2:> (def square (duplicate *))
<function call-duplicate>
repl:3:> (square 6)
36

#Reference

#apcl

apply, constant, duplicate, flip, left, recombine, right, under

#apply

function | source

(apply f)

Returns a function that applies f to a splice of its arguments.

#constant

function | source

(constant x)

Returns a function that always returns x.

#duplicate

function | source

(duplicate f)

Returns a function which, given one argument, calls f with that argument provided twice.

#flip

function | source

(flip f)

Returns a function which, given two arguments, calls f with those two arguments permuted.

#left

function | source

<function call-left>

A function which, given two arguments, returns the left one.

#recombine

function | source

(recombine f g h)

Returns a function that applies its arguments to g and h, taking the resulting values as the arguments to f.

function | source

<function call-right>

A function which, given two arguments, returns the right one.

#under

function | source

(under f g)

Returns a function that applies g to each of its arguments, taking the resulting values as the arguments to f.