Changeset 39586 in project
 Timestamp:
 02/08/21 17:26:57 (3 weeks ago)
 Location:
 release/5/dottedlambdas
 Files:

 6 edited
 1 copied
Legend:
 Unmodified
 Added
 Removed

release/5/dottedlambdas/tags/1.2/dottedlambdas.egg
r39485 r39586 3 3 ((synopsis "lambda equivalents with dots as trailing symbols") 4 4 (category langexts) 5 (version "1. 1")5 (version "1.2") 6 6 (license "BSD") 7 7 (testdependencies simpletests) 
release/5/dottedlambdas/tags/1.2/dottedlambdas.scm
r39485 r39586 79 79 With no argument it returns the encapsulated list and with one argument, 80 80 an index, returns the list's value at that index. 81 Returns the list's length with negative index. 81 82 ]# 82 83 (define (callable lst) … … 85 86 (() lst) 86 87 ((k) 87 (listref lst k))))) 88 (cond 89 ((negative? k) len) 90 ((>= k len) 91 (error 'callable "out of range" k)) 92 (else 93 (listref lst k))))))) 88 94 89 95 #[ 90 (lambda* (x ... xs ..) xpr . xprs) 91 (lambda* (x ... xs ...) xpr . xprs) 92 (lambda* (x ... xs ....) xpr . xprs) 93 (lambda* (x ...) xpr . xprs) 96 (lambda* (x !!! xs ..) xpr . xprs) 97 (lambda* (x !!! xs ...) xpr . xprs) 98 (lambda* (x !!! xs ....) xpr . xprs) 94 99  macro  95 the first three evaluate to (lambda (x ... . xs) xpr . xprs) 96 making xs callable and checkingif xs is of length at most 1,100 An alternative to (lambda (x ... . xs) xpr . xprs). 101 Makes xs callable and checks if xs is of length at most 1, 97 102 arbitrary or at least1, respectively. 98 The last one evaluates to ordinary (lambda (x ...) xpr . xprs)99 103 ]# 100 104 (definesyntax lambda* … … 114 118 (error 'lambda* "not enough arguments for ...." xs) 115 119 (let ((xs (callable xs))) xpr . xprs)))) 116 ((_ (x !!!) xpr . xprs) ; without dots: normal lambda117 (lambda (x !!!) xpr . xprs))118 120 )) 119 121 … … 121 123 122 124 #[ 123 (define* (name x ... xs ..) xpr . xprs) 124 (define* (name x ... xs ...) xpr . xprs) 125 (define* (name x ... xs ....) xpr . xprs) 126 (define* (name x ...) xpr . xprs) 125 (define* (name x !!! xs ..) xpr . xprs) 126 (define* (name x !!! xs ...) xpr . xprs) 127 (define* (name x !!! xs ....) xpr . xprs) 127 128  macro  128 129 syntactic sugar for, e.g. 129 (define name (lambda* (x ...xs ..) xpr . xprs))130 (define name (lambda* (x !!! xs ..) xpr . xprs)) 130 131 ]# 131 132 (definesyntax define* … … 137 138 ((_ (name x !!! xs ....) xpr . xprs) 138 139 (define name (lambda* (x !!! xs ....) xpr . xprs))) 139 ((_ (name x !!!) xpr . xprs)140 (define name (lambda* (x !!!) xpr . xprs)))141 140 )) 142 141 … … 157 156 "With no argument it returns the encapsulated list and with one argument," 158 157 "an index, returns the list's value at that index." 158 "Returns the list's length with negative index." 159 159 ) 160 160 (lambda* 161 161 macro: 162 (lambda* (x ... xs ..) xpr . xprs) 163 (lambda* (x ... xs ...) xpr . xprs) 164 (lambda* (x ... xs ....) xpr . xprs) 165 (lambda* (x ...) xpr . xprs) 166 "the first three evaluate to (lambda (x ... . xs) xpr . xprs)" 167 "making xs callable and checking if xs is of length at most 1," 162 (lambda* (x !!! xs ..) xpr . xprs) 163 (lambda* (x !!! xs ...) xpr . xprs) 164 (lambda* (x !!! xs ....) xpr . xprs) 165 "An alternative to (lambda (x ... . xs) xpr . xprs)." 166 "Makes xs callable and checks if xs is of length at most 1," 168 167 "arbitrary or at least1, respectively." 169 "The last one evaluates to ordinary (lambda (x ...) xpr . xprs)"170 168 ) 171 169 (define 172 170 macro: 173 (define* (name x ... xs ..) xpr . xprs) 174 (define* (name x ... xs ...) xpr . xprs) 175 (define* (name x ... xs ....) xpr . xprs) 176 (define* (name x ...) xpr . xprs) 177 (define name (lambda* (x ... xs ..) xpr . xprs)) 171 (define* (name x !!! xs ..) xpr . xprs) 172 (define* (name x !!! xs ...) xpr . xprs) 173 (define* (name x !!! xs ....) xpr . xprs) 174 (define name (lambda* (x !!! xs ..) xpr . xprs)) 178 175 "syntactic sugar for, e.g." 179 176 ) 
release/5/dottedlambdas/tags/1.2/tests/run.scm
r39485 r39586 3 3 (import simpletests (chicken base) (chicken condition)) 4 4 5 (define checks6 (calls verbose? lst (callable '(0 1 2 3)) lst0 (callable '()))5 (definetester 6 (calls? lst (callable '(0 1 2 3)) lst0 (callable '())) 7 7 (conditioncase (lst0 0) ((exn) #f)) 8 8 #f … … 11 11 (lst 3) 12 12 3 13 (lst 1) 14 4 13 15 (conditioncase (lst 5) ((exn) #f)) 14 #f15 (conditioncase (lst 1) ((exn) #f))16 16 #f) 17 17 18 (define checks19 (lambdas verbose?)18 (definetester 19 (lambdas?) 20 20 ((lambda* (xs ...) (list (xs 0) (xs 1) (xs 2))) 1 2 3) 21 21 '(1 2 3) … … 34 34 (conditioncase ((lambda* (x y zs ....) (list x y zs)) 1 2) ((exn) #f)) 35 35 #f 36 ((lambda* (a b) (list a b)) 1 2)37 '(1 2)38 36 ((lambda* (as ...) (as)) 1 2 3) 39 37 '(1 2 3) … … 49 47 (define* (baz xs ..) (list (xs))) 50 48 51 (define checks52 (defines verbose?)49 (definetester 50 (defines?) 53 51 (inc 5) 54 52 6 … … 68 66 #f) 69 67 70 ( checkall DOTTEDLAMBDAS71 (calls)72 (lambdas)73 (defines)68 (testall DOTTEDLAMBDAS 69 calls? 70 lambdas? 71 defines? 74 72 ) 
release/5/dottedlambdas/trunk/dottedlambdas.egg
r39485 r39586 3 3 ((synopsis "lambda equivalents with dots as trailing symbols") 4 4 (category langexts) 5 (version "1. 1")5 (version "1.2") 6 6 (license "BSD") 7 7 (testdependencies simpletests) 
release/5/dottedlambdas/trunk/dottedlambdas.scm
r39485 r39586 79 79 With no argument it returns the encapsulated list and with one argument, 80 80 an index, returns the list's value at that index. 81 Returns the list's length with negative index. 81 82 ]# 82 83 (define (callable lst) … … 85 86 (() lst) 86 87 ((k) 87 (listref lst k))))) 88 (cond 89 ((negative? k) len) 90 ((>= k len) 91 (error 'callable "out of range" k)) 92 (else 93 (listref lst k))))))) 88 94 89 95 #[ 90 (lambda* (x ... xs ..) xpr . xprs) 91 (lambda* (x ... xs ...) xpr . xprs) 92 (lambda* (x ... xs ....) xpr . xprs) 93 (lambda* (x ...) xpr . xprs) 96 (lambda* (x !!! xs ..) xpr . xprs) 97 (lambda* (x !!! xs ...) xpr . xprs) 98 (lambda* (x !!! xs ....) xpr . xprs) 94 99  macro  95 the first three evaluate to (lambda (x ... . xs) xpr . xprs) 96 making xs callable and checkingif xs is of length at most 1,100 An alternative to (lambda (x ... . xs) xpr . xprs). 101 Makes xs callable and checks if xs is of length at most 1, 97 102 arbitrary or at least1, respectively. 98 The last one evaluates to ordinary (lambda (x ...) xpr . xprs)99 103 ]# 100 104 (definesyntax lambda* … … 114 118 (error 'lambda* "not enough arguments for ...." xs) 115 119 (let ((xs (callable xs))) xpr . xprs)))) 116 ((_ (x !!!) xpr . xprs) ; without dots: normal lambda117 (lambda (x !!!) xpr . xprs))118 120 )) 119 121 … … 121 123 122 124 #[ 123 (define* (name x ... xs ..) xpr . xprs) 124 (define* (name x ... xs ...) xpr . xprs) 125 (define* (name x ... xs ....) xpr . xprs) 126 (define* (name x ...) xpr . xprs) 125 (define* (name x !!! xs ..) xpr . xprs) 126 (define* (name x !!! xs ...) xpr . xprs) 127 (define* (name x !!! xs ....) xpr . xprs) 127 128  macro  128 129 syntactic sugar for, e.g. 129 (define name (lambda* (x ...xs ..) xpr . xprs))130 (define name (lambda* (x !!! xs ..) xpr . xprs)) 130 131 ]# 131 132 (definesyntax define* … … 137 138 ((_ (name x !!! xs ....) xpr . xprs) 138 139 (define name (lambda* (x !!! xs ....) xpr . xprs))) 139 ((_ (name x !!!) xpr . xprs)140 (define name (lambda* (x !!!) xpr . xprs)))141 140 )) 142 141 … … 157 156 "With no argument it returns the encapsulated list and with one argument," 158 157 "an index, returns the list's value at that index." 158 "Returns the list's length with negative index." 159 159 ) 160 160 (lambda* 161 161 macro: 162 (lambda* (x ... xs ..) xpr . xprs) 163 (lambda* (x ... xs ...) xpr . xprs) 164 (lambda* (x ... xs ....) xpr . xprs) 165 (lambda* (x ...) xpr . xprs) 166 "the first three evaluate to (lambda (x ... . xs) xpr . xprs)" 167 "making xs callable and checking if xs is of length at most 1," 162 (lambda* (x !!! xs ..) xpr . xprs) 163 (lambda* (x !!! xs ...) xpr . xprs) 164 (lambda* (x !!! xs ....) xpr . xprs) 165 "An alternative to (lambda (x ... . xs) xpr . xprs)." 166 "Makes xs callable and checks if xs is of length at most 1," 168 167 "arbitrary or at least1, respectively." 169 "The last one evaluates to ordinary (lambda (x ...) xpr . xprs)"170 168 ) 171 169 (define 172 170 macro: 173 (define* (name x ... xs ..) xpr . xprs) 174 (define* (name x ... xs ...) xpr . xprs) 175 (define* (name x ... xs ....) xpr . xprs) 176 (define* (name x ...) xpr . xprs) 177 (define name (lambda* (x ... xs ..) xpr . xprs)) 171 (define* (name x !!! xs ..) xpr . xprs) 172 (define* (name x !!! xs ...) xpr . xprs) 173 (define* (name x !!! xs ....) xpr . xprs) 174 (define name (lambda* (x !!! xs ..) xpr . xprs)) 178 175 "syntactic sugar for, e.g." 179 176 ) 
release/5/dottedlambdas/trunk/tests/run.scm
r39485 r39586 3 3 (import simpletests (chicken base) (chicken condition)) 4 4 5 (define checks6 (calls verbose? lst (callable '(0 1 2 3)) lst0 (callable '()))5 (definetester 6 (calls? lst (callable '(0 1 2 3)) lst0 (callable '())) 7 7 (conditioncase (lst0 0) ((exn) #f)) 8 8 #f … … 11 11 (lst 3) 12 12 3 13 (lst 1) 14 4 13 15 (conditioncase (lst 5) ((exn) #f)) 14 #f15 (conditioncase (lst 1) ((exn) #f))16 16 #f) 17 17 18 (define checks19 (lambdas verbose?)18 (definetester 19 (lambdas?) 20 20 ((lambda* (xs ...) (list (xs 0) (xs 1) (xs 2))) 1 2 3) 21 21 '(1 2 3) … … 34 34 (conditioncase ((lambda* (x y zs ....) (list x y zs)) 1 2) ((exn) #f)) 35 35 #f 36 ((lambda* (a b) (list a b)) 1 2)37 '(1 2)38 36 ((lambda* (as ...) (as)) 1 2 3) 39 37 '(1 2 3) … … 49 47 (define* (baz xs ..) (list (xs))) 50 48 51 (define checks52 (defines verbose?)49 (definetester 50 (defines?) 53 51 (inc 5) 54 52 6 … … 68 66 #f) 69 67 70 ( checkall DOTTEDLAMBDAS71 (calls)72 (lambdas)73 (defines)68 (testall DOTTEDLAMBDAS 69 calls? 70 lambdas? 71 defines? 74 72 )
Note: See TracChangeset
for help on using the changeset viewer.