• 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

修订版609bc590fff8bb6e9a6a24e3426c943d9937c5ef (tree)
时间2022-03-10 12:09:04
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Decide on the order of lists and fix fold.

更改概述

差异

--- a/cammy-rpy/cammylib/arrows.py
+++ b/cammy-rpy/cammylib/arrows.py
@@ -300,6 +300,9 @@ class PrimRec(Arrow):
300300 cs.unify(fdom, fcod)
301301 return cs.concrete("N"), fcod
302302
303+# NB: Lists are built from left-to-right; [0, 1] is
304+# (cons 1 (cons 0 nil))
305+
303306 class Nil(Arrow):
304307 _immutable_ = True
305308 def run(self, x): return Xs([])
@@ -308,7 +311,7 @@ class Nil(Arrow):
308311
309312 class Cons(Arrow):
310313 _immutable_ = True
311- def run(self, x): return Xs([x.first()] + x.second().l())
314+ def run(self, x): return Xs(x.second().l() + [x.first()])
312315 def types(self, cs):
313316 x = cs.fresh()
314317 xs = cs.functor("list", [x])
--- a/hive/fun/apppair.cammy
+++ b/hive/fun/apppair.cammy
@@ -1 +1,3 @@
1-(comp (pair @0 @1) fun/app)
1+(pair/of fun/app @0 @1)
2+
3+Apply the output of one arrow onto the output of another.
--- /dev/null
+++ b/hive/list/conspair.cammy
@@ -0,0 +1,4 @@
1+(pair/of cons @0 @1)
2+
3+Build a list whose head is the output of one arrow and whose tail is the
4+output of another arrow.
--- /dev/null
+++ b/hive/list/reverse-onto.cammy
@@ -0,0 +1,6 @@
1+(uncurry (fold (fun/name id)
2+ (curry (fun/apppair
3+ (comp fst snd)
4+ (list/conspair (comp fst fst) snd)))))
5+
6+Reverse a list onto an input suffix.
--- /dev/null
+++ b/hive/list/reverse.cammy
@@ -0,0 +1,3 @@
1+(comp (pair id (fun/const nil)) list/reverse-onto)
2+
3+Reverse a list in linear time.
--- /dev/null
+++ b/hive/list/singleton.cammy
@@ -0,0 +1,3 @@
1+(comp (pair id (fun/const nil)) cons)
2+
3+A list with only one value.
--- /dev/null
+++ b/hive/subobj/complement.cammy
@@ -0,0 +1,3 @@
1+(curry (comp fun/app not))
2+
3+The complement of a subobject.
--- /dev/null
+++ b/hive/subobj/conj.cammy
@@ -0,0 +1,7 @@
1+(curry (comp
2+ (pair
3+ (fun/apppair (comp fst fst) snd)
4+ (fun/apppair (comp fst snd) snd))
5+ conj))
6+
7+The intersection of two subobjects.
--- /dev/null
+++ b/hive/subobj/disj.cammy
@@ -0,0 +1,7 @@
1+(curry (comp
2+ (pair
3+ (fun/apppair (comp fst fst) snd)
4+ (fun/apppair (comp fst snd) snd))
5+ disj))
6+
7+The union of two subobjects.
--- /dev/null
+++ b/hive/subobj/empty.cammy
@@ -0,0 +1,3 @@
1+(fun/const f)
2+
3+An empty subobject.
--- /dev/null
+++ b/hive/subobj/full.cammy
@@ -0,0 +1,3 @@
1+(fun/const t)
2+
3+A subobject that is just the original object.