in k: xs: 1 2 3 4 5 max: 4 min: 2 max& min| xs 2 2 3 4 4 works for scalar, vector, matrix
max . nums
or equivalently: min >. max 51–60 of 291 posts
in k: xs: 1 2 3 4 5 max: 4 min: 2 max& min| xs 2 2 3 4 4 works for scalar, vector, matrix
max . nums
or equivalently: min >. max Earlier quoted context omitted.
Very good point. I thought of it more as pseudocode.
imho a very elegant solution and probably works in most languages, I was surprised by JavaScript's behaviour myself
Luckily, this is a solved problem for go. func helper(a float64, c chan float64){ time.Sleep(time.Duration(a) * time.Second) c
Earlier quoted context omitted.
imho a very elegant solution and probably works in most languages, I was surprised by JavaScript's behaviour myself
For a real fun headscratcher consider [ '9', '10', '11', '12', '13' ].map(parseInt)
[ROT 13] spoiler: cnefrVag frpbaq nethzrag vf onfr, znc frpbaq nethzrag vf vaqrk va neenl. 10 vf gur frpbaq nethzrag, vaqrk 1. cnefrVag(10, 1) unf vyyrtny onfr
Fun seeing that pretty much everyone else finds that idiom confusing too. Half-serious, over breakfast: (case [(> n min) ( (Side note: Clojure's `>` and ` n min)` into "if n is greater than min" takes some work for me, still, after more than a year.)
(> 3 2 1 ...)
vs (3 > 2) && (2 > 1) && ...I find that the fact that the functions min and max have the same name as the variables min and max increases cognitive load which makes it harder to think about it. I find the following easier to read : Math.min(Math.max(num, lower_bound), upper_bound)
clamped = num `max` min' `min` max'Fun seeing that pretty much everyone else finds that idiom confusing too. Half-serious, over breakfast: (case [(> n min) ( (Side note: Clojure's `>` and ` n min)` into "if n is greater than min" takes some work for me, still, after more than a year.)
(-> n
(max vmin)
(min vmax)) sorted((floor, x, ceiling))[1]
Throw it in a function with some asserts if you're worried about x not being a number and giving you weird results.