From b68307db49807c83860f4303a05d08f25dbf6375 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Sat, 20 Aug 2022 22:30:31 +0200
Subject: Parser shenanigans

---
 std/Pair.bruijn | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

(limited to 'std/Pair.bruijn')

diff --git a/std/Pair.bruijn b/std/Pair.bruijn
index b21d193..8dffe7d 100644
--- a/std/Pair.bruijn
+++ b/std/Pair.bruijn
@@ -8,35 +8,40 @@ pair [[[0 2 1]]]
 (:) pair
 
 # extracts first expression from pair
-fst [0 K]
+fst [0 k]
 
 ^( fst
 
-# test fst with example pair of [[0]] and [[1]]
 :test (^([[0]] : [[1]])) ([[0]])
 
 # extracts second expression from pair
-snd [0 KI]
+snd [0 ki]
 
 ~( snd
 
-# test snd with example pair of [[0]] and [[1]]
 :test (~([[0]] : [[1]])) ([[1]])
 
 # applies both elements of a pair to a function
 uncurry [[1 ^0 ~0]]
 
-# test uncurry with example pair of [[0]] and [[1]] and some combinator
-:test (uncurry W ([[0]] : [[1]])) ([[1]])
+:test (uncurry w ([[0]] : [[1]])) ([[1]])
 
 # applies a function to the pair of two values
 curry [[[2 (1 : 0)]]]
 
-# test curry with example pair of [[0]] and [[1]] and fst
 :test (curry fst [[0]] [[1]]) ([[0]])
 
-# swaps the values of a pair
+# zips two pairs (basically rotating the elements)
+zip [[(^1 : ^0) : (~1 : ~0)]]
+
+:test (zip ([[0]] : [[[0]]]) ([[1]] : [[[1]]])) (([[0]] : [[1]]) : ([[[0]]] : [[[1]]]))
+
+# applies pairs of two pairs as arguments to a function
+zip-with [[[(2 ^1 ^0) : (2 ~1 ~0)]]]
+
+:test (zip-with w ([[0]] : [[[0]]]) ([[1]] : [[[1]]])) ([[1]] : [0])
+
+# swaps the elements of a pair
 swap [~0 : ^0]
 
-# test swap with example pair of [[0]] and [[1]]
 :test (swap ([[0]] : [[1]])) ([[1]] : [[0]])
-- 
cgit v1.2.3