-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std/misc/func: pred-and & pred-or #514
std/misc/func: pred-and & pred-or #514
Conversation
0616516
to
a6bb977
Compare
I was actually thinking of not invoking the predicate at all if we are short-circuiting; not sure if it can be written with chain though. |
a6bb977
to
eade74b
Compare
src/std/misc/func.ss
Outdated
(def (pred-and pred) | ||
(def res #t) | ||
(lambda (v) | ||
(match res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't quite need match
here, just an if
will do :)
src/std/misc/func.ss
Outdated
(def res #t) | ||
(lambda (v) | ||
(match res | ||
(#t (set! res (and res (pred v))) res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to and
, it's already #t
.
src/std/misc/func.ss
Outdated
(def (pred-or pred) | ||
(def res #f) | ||
(lambda (v) | ||
(match res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here, just if
.
src/std/misc/func.ss
Outdated
(def res #f) | ||
(lambda (v) | ||
(match res | ||
(#f (set! res (or res (pred v))) res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here the or
is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll should go and sleep again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, yeah, I have mornings like that too...
eade74b
to
825411e
Compare
825411e
to
01cb74a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
pred-and
allows to check if apred
holds on multiple circumstances without constructing a filtered list of to-be-checked items beforehand.