• 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

修订版e6929cea3d82f54de43e8eb5a6bdb0904daa130e (tree)
时间2021-08-18 01:18:12
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Compile sums to Scheme.

更改概述

差异

--- a/finish.py
+++ b/finish.py
@@ -25,8 +25,8 @@ with open("stub.scm", "r", encoding="utf-8") as handle:
2525
2626 with open(sys.argv[-2], "r", encoding="utf-8") as handle:
2727 program = handle.read().strip()
28- program = program.replace("cons", "cammy-cons")
29- program = program.replace("map", "cammy-map")
28+ for comb in ("case", "cons", "map"):
29+ program = program.replace(comb, "cammy-" + comb)
3030 print("(define program {})".format(program))
3131
3232 print("""
--- a/shell.nix
+++ b/shell.nix
@@ -7,7 +7,8 @@ in pkgs.stdenv.mkDerivation {
77 # debugging native code
88 gdb
99 # debugging stub.scm
10- chicken rlwrap
10+ chicken rlwrap ] ++
11+ (with chickenPackages.chickenEggs; [ srfi-189 ]) ++ [
1112 # maintaining frame/
1213 ocamlformat
1314 # debugging stub.ml
--- a/stub.scm
+++ b/stub.scm
@@ -1,7 +1,5 @@
1-(import (srfi 6))
2-(import (chicken condition))
3-(import (chicken format))
4-(import (chicken string))
1+(import (srfi 6) (srfi 189))
2+(import (chicken condition) (chicken format) (chicken string))
53
64 (define id (lambda (x) x))
75 (define (comp f g) (lambda (x) (g (f x))))
@@ -14,6 +12,8 @@
1412
1513 (define swap (lambda (x) (cons (cdr x) (car x))))
1614
15+(define (cammy-case f g) (lambda (x) (either-ref x f g)))
16+
1717 (define (curry f) (lambda (x) (lambda (y) (f (cons x y)))))
1818 (define (uncurry f) (lambda (xy) ((f (car xy)) (cdr xy))))
1919 (define app (lambda (fx) ((car fx) (cdr fx))))