Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We have 3 possible situations, only one at a time is applicable to a collection. </p> <ul> <li>The collections has items and they all pas the predicate - True</li> <li>One of the item in the coll failed the predicate - False</li> <li>The coll is empty - ??</li> </ul> <p>Now if you think about returning false for empty list, it would also feel weird because false is returned when at least one item in the coll failed the predicate but for empty list that didn't happened.</p> <p>I think the rational to choose true for empty coll was based on the fact that the number of cases where this is applicable in real world were more as compared to where it would not make sense. For example: Someone gave me a list of URLs and I need to return their downloaded content, now my function first want to verify that each URL is in proper format and then use map or pmap to download the URLs -</p> <pre><code>(if (every? url? urls) (map download urls) (throw "Invalid url found")) </code></pre> <p>This and more examples of this kind will make working with sequences more seamless.</p> <p>On the other hand I am a statically typed language guy (like Haskell) and would prefer to use types to solve this problem. Rather than returning a true or false I would want this function to return <code>Maybe bool</code> such that:</p> <ul> <li>Every item in the coll pass the predicate - <code>Just True</code></li> <li>One of the item in the coll failed the predicate - <code>Just False</code></li> <li>The coll is empty - <code>Nothing</code></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload