Hacker News new | ask | show | jobs
by rixed 265 days ago
From the readme:

  [1, 2, 3] * 10  // [10, 20, 30] (because [1 * 10 = 10, 2 * 10 = 20, 3 * 10 = 30])
  [4, 5, 6] > 3 // true (because [4 > 3 = true, 5 > 3 = true, 6 > 3 = true], so the condition is true for all elements)
I guess most people would have expected that second expression to return

  [true, true, true]
Is this really more practical to single out booleans like that, compared to having a separate step for ANDing?
1 comments

Hey! I've received this feedback from a few different people, and I agree with it. The latest version of Blots (0.8.0) changes the behavior of broadcast comparisons. Now, comparisons are applied to each element in the list, producing a new list of booleans. As you pointed out, this better matches the broadcasting behavior of arithmetic operators:

``` [1, 2, 3] * 10 // [10, 20, 30] [10, 20, 30] + 2 // [12, 22, 32] [4, 5, 6] > 3 // [true, true, true] [1, 2] == [2, 2] // [false, true] ```

In addition, I’ve added both `all` and `any` as built-in functions. These can be used to achieve the same result as the previous broadcasting behavior:

``` [4, 5, 6] > 4 into all // false [4, 5, 6] > 4 into any // true

// alternatively: all([4, 5, 6] > 4) // false any([4, 5, 6] > 4) // true ```

Thanks for the feedback!