mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Add min-of and max-of.
This commit is contained in:
		| @@ -698,6 +698,14 @@ | |||||||
|   "Returns the numeric minimum of the arguments." |   "Returns the numeric minimum of the arguments." | ||||||
|   [& args] (extreme < args)) |   [& 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 | (defn first | ||||||
|   "Get the first element from an indexed data structure." |   "Get the first element from an indexed data structure." | ||||||
|   [xs] |   [xs] | ||||||
|   | |||||||
| @@ -234,6 +234,9 @@ static void add_timeout(JanetTimeout to) { | |||||||
|  |  | ||||||
| /* Create a new event listener */ | /* Create a new event listener */ | ||||||
| static JanetListenerState *janet_listen_impl(JanetStream *stream, JanetListener behavior, int mask, size_t size, void *user) { | 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) { |     if (stream->_mask & mask) { | ||||||
|         janet_panic("cannot listen for duplicate event on stream"); |         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); |         CloseHandle(stream->handle); | ||||||
|     } |     } | ||||||
|  |     stream->handle = INVALID_HANDLE_VALUE; | ||||||
| #else | #else | ||||||
|     close(stream->handle); |     close(stream->handle); | ||||||
|  |     stream->handle = -1; | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose