summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@eta.mit.edu>2009-02-12 13:46:00 -0500
committerbnewbold <bnewbold@eta.mit.edu>2009-02-12 13:46:00 -0500
commitd63676b79430cac0b54bf50de5564a533866f9e2 (patch)
tree7232806cbcdbc39c1ef7e9b5decb2b8d99b99c61
parent8e998f4e5be326a2bc91220e86d555ce79d2890e (diff)
download6.945-d63676b79430cac0b54bf50de5564a533866f9e2.tar.gz
6.945-d63676b79430cac0b54bf50de5564a533866f9e2.zip
typo correction
-rw-r--r--ps01_grep/ps01_bnewbold.txt18
-rw-r--r--ps01_grep/ps01_work.scm45
2 files changed, 55 insertions, 8 deletions
diff --git a/ps01_grep/ps01_bnewbold.txt b/ps01_grep/ps01_bnewbold.txt
index 52979e7..8968157 100644
--- a/ps01_grep/ps01_bnewbold.txt
+++ b/ps01_grep/ps01_bnewbold.txt
@@ -174,7 +174,7 @@ c) (not, uh, fully tested...)
(let ((choose-grep (lambda (x)
(cond
((string? x) x)
- ((list? x) (car x))))))
+ ((list? x) ((car x)))))))
(apply string-append (map choose-grep exprs))))
(r-grep:seq "a" "b" '("grep" "egrep"))
@@ -184,7 +184,7 @@ c) (not, uh, fully tested...)
(let ((choose-egrep (lambda (x)
(cond
((string? x) x)
- ((list? x) (cadr x))))))
+ ((list? x) ((cadr x)))))))
(apply string-append (map choose-egrep exprs))))
#| test:
@@ -340,6 +340,20 @@ c) (not, uh, fully tested...)
(r:grep-like "grep" '("-E") ((cadr expr)) filename)
(r:grep-like "egrep" '() ((cadr expr)) filename)))
+#| final tests:
+(r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))
+;Value: (#[compound-procedure 18] #[compound-procedure 19])
+((car (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))))
+;Value: "\\(cat\\)\\{2,3\\}\\(dog\\)\\{1,\\}"
+((cadr (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))))
+;Value: "(cat){2,3}(dog){1,}"
+
(pp (r:grep (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))
"tests.txt"))
+; ("[10]. catcatdogdog" "[12]. catcatcatdogdogdog")
+(pp (r:egrep (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))
+ "tests.txt"))
+; ("[10]. catcatdogdog" "[12]. catcatcatdogdogdog")
+
+|#
diff --git a/ps01_grep/ps01_work.scm b/ps01_grep/ps01_work.scm
index 7338f20..a38cc9c 100644
--- a/ps01_grep/ps01_work.scm
+++ b/ps01_grep/ps01_work.scm
@@ -155,17 +155,14 @@
(let ((choose-grep (lambda (x)
(cond
((string? x) x)
- ((list? x) (car x))))))
+ ((list? x) ((car x)))))))
(apply string-append (map choose-grep exprs))))
-(r-grep:seq "a" "b" '("grep" "egrep"))
-; abgrep
-
(define (r-egrep:seq . exprs)
(let ((choose-egrep (lambda (x)
(cond
((string? x) x)
- ((list? x) (cadr x))))))
+ ((list? x) ((cadr x)))))))
(apply string-append (map choose-egrep exprs))))
#| test:
@@ -284,6 +281,30 @@
(cons (lambda () (r-grep:repeat min max expr))
(cons (lambda () (r-egrep:repeat min max expr)) '())))
+#| tests:
+(r-grep:repeat 1 3 "d")
+;Value: "\\(d\\)\\{1,3\\}"
+(r-egrep:repeat 1 3 "d")
+;Value: "(d){1,3}"
+((car (r:repeat 2 2 "asdf")))
+;Value: "\\(asdf\\)\\{2\\}"
+((cadr (r:repeat 2 2 "asdf")))
+;Value: "(asdf){2}"
+
+((cadr (r:repeat 3 #f "asdf")))
+;Value: "(asdf){3,}"
+
+(r:+ "asdf")
+;Value: (#[compound-procedure 21] #[compound-procedure 22])
+((car (r:+ "asdf")))
+;Value: "\\(asdf\\)\\{1,\\}"
+
+((car (r:+ (r:+ (r:quote "a")))))
+;Value: "\\(\\(a\\)\\{1,\\}\\)\\{1,\\}"
+
+((car (r:seq (r:quote "a"))))
+|#
+
(define (r-grep:subexp . exprs)
(string-append "\\(" (apply string-append
(map (lambda (x)
@@ -321,10 +342,22 @@
(r:grep-like "grep" '("-E") ((cadr expr)) filename)
(r:grep-like "egrep" '() ((cadr expr)) filename)))
+#| final tests:
+(r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))
+;Value: (#[compound-procedure 18] #[compound-procedure 19])
+((car (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))))
+;Value: "\\(cat\\)\\{2,3\\}\\(dog\\)\\{1,\\}"
+((cadr (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))))
+;Value: "(cat){2,3}(dog){1,}"
+
(pp (r:grep (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))
"tests.txt"))
+; ("[10]. catcatdogdog" "[12]. catcatcatdogdogdog")
+(pp (r:egrep (r:seq (r:repeat 2 3 (r:quote "cat")) (r:+ (r:quote "dog")))
+ "tests.txt"))
+; ("[10]. catcatdogdog" "[12]. catcatcatdogdogdog")
-
+|#