• 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

修订版9874abe37efb128d50beb15094374b5e144a39bb (tree)
时间2021-08-09 05:51:52
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Require nats to be positive.

更改概述

差异

--- a/finish.py
+++ b/finish.py
@@ -5,7 +5,7 @@ import sys
55 parsers = {
66 "unit": "string->unit",
77 "bool": "string->boolean",
8- "nat": "string->number",
8+ "nat": "string->nat",
99 "nat * nat": "string->int",
1010 }
1111
--- a/stub.scm
+++ b/stub.scm
@@ -1,3 +1,5 @@
1+(import (chicken condition))
2+
13 (define id (lambda (x) x))
24 (define (comp f g) (lambda (x) (g (f x))))
35
@@ -30,6 +32,10 @@
3032
3133 (define (string->unit s) '())
3234 (define (string->boolean s) (equal? s "true"))
35+(define (string->nat s)
36+ (let ((i (string->number s)))
37+ (if (< i 0) (signal (condition '(exn message "nats must be positive")))
38+ i)))
3339 (define (string->int s)
3440 (let ((i (string->number s))) (if (< i 0) (cons 0 (abs i)) (cons i 0))))
3541 (define (fold-left kn kc l) (if (null? l) kn (kc (car l) (fold-left kn kc (cdr l)))))