From 9d722a0b6138827de743f9fe4acbf3f2c1830bb0 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 6 Nov 2023 00:24:11 +0100 Subject: Started creating new docs with wiki --- docs/wiki_src/coding/mixfix.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docs/wiki_src/coding/mixfix.md (limited to 'docs/wiki_src/coding/mixfix.md') diff --git a/docs/wiki_src/coding/mixfix.md b/docs/wiki_src/coding/mixfix.md new file mode 100644 index 0000000..c85b936 --- /dev/null +++ b/docs/wiki_src/coding/mixfix.md @@ -0,0 +1,33 @@ +# Mixfix + +Mixfix functions allow arbitrary infix operations based on "substitution +holes" by using the `…` symbol in (special character) definitions. The +symbols and terms always need to be delimited by a space character, else +they get interpreted as a [prefix](prefix.md). + +Example: + +``` bruijn +…+… add + +# the "holes" get applied in normal order +:test ((+4) + (+3)) (add (+4) (+3)) +``` + +You can define as many holes as you like. Make sure to place parenthesis +for applications inside substitution holes. + +``` bruijn +{…<$>…|… [[[2 - 1 + 0]]] + +# evaluated as (5 - 2) + 1 = 4 +:test ({ (+5) <$> (+2) | (+1)) ((+4)) +:test ({ ((+3) + (+1)) <$> (+2) | (+1)) ((+4)) +``` + +You can use them as normal functions by writing the identifier +literally: + +``` bruijn +:test (…+… (+4) (+3)) (add (+4) (+3)) +``` -- cgit v1.2.3