Note that there are some explanatory texts on larger screens.

plurals
  1. USWarbo
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. CO@peterwkc Haskell uses spaces to separate function names from their arguments (eg. "foo x y") unlike many other languages which use brackets and commas (eg. "foo(x, y)"). Here, "f" is a function with one argument. That argument is a list of characters (a string). We can use recursion as long as the string is getting shorter. "f []" is the non-recursive base case, "f ('\n':' ':a)" recurses on "('\n':a)" which is one char shorter, "f (a:b)" recurses on "b" which is one char shorter. "x:y:z" is the syntax for a list.
      singulars
    2. COTo clarify: `list($x) = foo();` is equivalent to `$x = foo()[0];`. Note that this is not necessarily the same as "get the first item", since even an integer-indexed array may not have an element with key 0. In my case I was doing "list($order) = get_order($user);" but "get_order" was returning orders keyed by their ID, which was usually not 0. As @Sergiy says, array_values() fixes this, but detracts from the efficiency and (more importantly) readability of the code.
      singulars
    3. CO@AlixAxel You're right that multi-dimensional != bi-dimensional, but this can be composed to flatten any number of levels. One nice consequence of composing folds is that it obeys a fixed limit; if I have an array nested to 5 levels, I can `fold` it into 4 levels, or `fold . fold` it to get 3 levels, or `fold . fold . fold` it to get 2 levels, etc. This also prevents bugs getting hidden; eg. if I want to flatten a 5D array but I'm given a 4D array, the error will trigger immediately.
      singulars
 

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