• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

A categorical programming language


Commit MetaInfo

修订版57c6a0966f649cd6dc613776a0c6feaeb2042c16 (tree)
时间2021-11-27 05:18:14
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Start building basic literate tools.

更改概述

差异

--- /dev/null
+++ b/cammy-weave.py
@@ -0,0 +1,32 @@
1+#!@python3@/bin/python3
2+
3+import sys
4+
5+def offset_list(s):
6+ count = 0
7+ for i, c in enumerate(s):
8+ if c == '(':
9+ count += 1
10+ elif c == ')':
11+ count -= 1
12+ if not count:
13+ return i + 1
14+ raise Exception("Runaway Cammy expression has %d unclosed parentheses" % count)
15+
16+def offset_atom(s):
17+ for i, c in enumerate(s):
18+ if c == ' ' or c == '\n':
19+ return i
20+ return len(s)
21+
22+def untangle(s):
23+ offset = offset_list(s) if s.startswith('(') else offset_atom(s)
24+ return s[:offset], s[offset:].strip()
25+
26+if __name__ == "__main__":
27+ expr, doc = untangle(sys.stdin.read())
28+ command = sys.argv[1]
29+ if command == "strip":
30+ print(expr)
31+ else:
32+ raise Exception("Unknown command %s" % command)
--- a/default.nix
+++ b/default.nix
@@ -21,7 +21,7 @@ in pkgs.stdenv.mkDerivation {
2121
2222 buildInputs = [ pkgs.makeWrapper ];
2323
24- inherit (pkgs) bash chicken;
24+ inherit (pkgs) bash chicken python3;
2525 inherit CHICKEN_REPOSITORY_PATH CHICKEN_INCLUDE_PATH frame jelly movelist;
2626
2727 installPhase = ''
@@ -39,6 +39,10 @@ in pkgs.stdenv.mkDerivation {
3939 --subst-var frame --subst-var jelly --subst-var movelist
4040 chmod +x $out/bin/cammy-simplify
4141
42+ substitute $src/cammy-weave.py $out/bin/cammy-weave \
43+ --subst-var python3
44+ chmod +x $out/bin/cammy-weave
45+
4246 makeWrapper ${movelist}/bin/movelist $out/bin/cammy-movelist
4347
4448 makeWrapper ${cammy-run}/bin/cammy-run $out/bin/cammy-draw
--- a/frame/dune-project
+++ b/frame/dune-project
@@ -1,3 +1,3 @@
1-(lang dune 2.9)
1+(lang dune 2.8)
22 (name frame)
33 (package (name frame) (synopsis "Recursively expand Cammy programs"))
--- a/hive/nat/add.cammy
+++ b/hive/nat/add.cammy
@@ -1 +1,4 @@
1-(uncurry (pr (curry snd) (curry (comp fun/app succ))))
1+(uncurry
2+ (pr
3+ (fun/name id)
4+ (curry (comp fun/app succ))))
--- a/todo.txt
+++ b/todo.txt
@@ -15,3 +15,4 @@
1515 * Remove movelist djinn, maybe?
1616 * Double-negation monad for CPS?
1717 * fun/name should always start from 1
18+* Prove that nat/add is smallest with its behavior