Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
parenscript
parenscript
Commits
3747e18b
Verified
Commit
3747e18b
authored
Oct 20, 2018
by
Vladimir Sedach
Browse files
Make RANDOM generate floats correctly
parent
b975f7d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/macros.lisp
View file @
3747e18b
...
...
@@ -109,7 +109,10 @@
`
(
/
(
log
,
n
)
(
log
,
base
))))
(
sqrt
(
n
)
`
((
@
*math
sqrt
)
,
n
))
(
random
(
&optional
upto
)
(
if
upto
`
(
floor
(
*
,
upto
(
random
)))
(
maybe-once-only
(
upto
)
`
(
if
(
rem
,
upto
1
)
(
*
,
upto
(
random
))
(
floor
(
*
,
upto
(
random
)))))
'
(
funcall
(
@
*math
random
)))))
(
defpsmacro
ash
(
integer
count
)
...
...
tests/eval-tests.lisp
View file @
3747e18b
...
...
@@ -868,3 +868,21 @@
"odd"
))
(
bar
9
))
"odd"
)
(
test-js-eval
random-float-const
(
<
0
(
rem
(
random
123.456
)
1
)
1
)
t
)
(
test-js-eval
random-int-const
(
rem
(
random
234
)
1
)
0
)
(
test-js-eval
random-float-fun-once-only
(
let
((
x
t
))
(
flet
((
foo
()
(
prog1
(
if
x
123.123
(
throw
"foobar"
))
(
setf
x
nil
))))
(
<
0
(
rem
(
random
(
foo
))
1
)
1
)))
t
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment