1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-29 03:19:54 +00:00

Add min-of and max-of.

This commit is contained in:
Calvin Rose 2021-10-26 17:46:24 -05:00
parent 06aa0a124d
commit 8b2d278840
2 changed files with 13 additions and 0 deletions

View File

@ -698,6 +698,14 @@
"Returns the numeric minimum of the arguments."
[& args] (extreme < args))
(defn max-of
"Returns the numeric maximum of the argument sequence."
[args] (extreme > args))
(defn min-of
"Returns the numeric minimum of the argument sequence."
[args] (extreme < args))
(defn first
"Get the first element from an indexed data structure."
[xs]

View File

@ -234,6 +234,9 @@ static void add_timeout(JanetTimeout to) {
/* Create a new event listener */
static JanetListenerState *janet_listen_impl(JanetStream *stream, JanetListener behavior, int mask, size_t size, void *user) {
if (stream->flags & JANET_STREAM_CLOSED) {
janet_panic("cannot listen on closed stream");
}
if (stream->_mask & mask) {
janet_panic("cannot listen for duplicate event on stream");
}
@ -344,8 +347,10 @@ static void janet_stream_close_impl(JanetStream *stream, int is_gc) {
{
CloseHandle(stream->handle);
}
stream->handle = INVALID_HANDLE_VALUE;
#else
close(stream->handle);
stream->handle = -1;
#endif
}