You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(define prime?
X -> (prime-h? X (isqrt X) 2))
(define isqrt
X -> (isqrt-help X 1))
(define isqrt-help
X Y -> Y where (= (* Y Y) X)
X Y -> (- Y 1) where (> (* Y Y) X)
X Y -> (isqrt-help X (+ Y 1)))
(define prime-h?
X Max Div -> true where (> Div Max)
X Max Div -> false where (integer? (/ X Div))
X Max Div -> (prime-h? X Max (+ 1 Div)))
Now, load it into the REPL:
(0-) (load "/home/aarroyoc/dev/shen/primes.shen")
prime?
isqrt
isqrt-help
prime-h?
loaded
(1-) (prime? 12)
error: application: not a procedure;
expected a procedure that can be applied to arguments
given: 'isqrt
context...:
body of top-level
.../lang/syntax-utils.rkt:433:44: prime?
.../private/parse-interp.rkt:643:50
.../scryer-shen/repl.rkt:28:0: shen-repl
body of '#%mzc:repl
(2-) (load "/home/aarroyoc/dev/shen/primes.shen")
prime?
isqrt
error: isqrt-help: identifier's binding is ambiguous
in: isqrt-help
context...:
#(-3699 interned function) #(8132 local) #(8135 local) #(8136 intdef)
#(8147 local) #(8148 intdef) #(8150 local) #(8157 intdef)
#(8162 local) #(8163 intdef) #(8166 local) #(8167 letrec-body)
#(8169 intdef) #(8172 local) #(8173 intdef) #(8175 local)
#(8176 intdef) #(8178 local) #(8179 intdef) #(8181 local)
#(8182 intdef) [common scopes]
matching binding...:
local
#(8132 local) [common scopes]
matching binding...:
#(isqrt-help.1 #<module-path-index:top-level> 0)
#(-3699 interned function) [common scopes]
common scopes...:
#(0 module) #(7395/2 module top-level)
context...:
.../private/stxparam.rkt:63:2
.../private/parse-interp.rkt:643:50
.../lang/load.rkt:112:4
.../lang/load.rkt:108:0: body of top-level
.../private/parse-interp.rkt:643:50
.../scryer-shen/repl.rkt:28:0: shen-repl
body of '#%mzc:repl
(3-) (prime? 12)
false
As it's visible from the interaction, the first load didn't really load some functions, so trying to execute them gives an error. Reloading again, even if it shows an error, fixes the issue. I suspect it has to do with the order in which functions are defined.
The text was updated successfully, but these errors were encountered:
Take a file named
primes.shen
with this content:Now, load it into the REPL:
As it's visible from the interaction, the first load didn't really load some functions, so trying to execute them gives an error. Reloading again, even if it shows an error, fixes the issue. I suspect it has to do with the order in which functions are defined.
The text was updated successfully, but these errors were encountered: