Reports a flat list of the maximum size of the input array along each dimension: number of rows, number of columns, etc. "Maximum" because it works even if the array isn't uniformly shaped.
Reports the greater of its two inputs. Works on strings too.
Reports a flat list of all the atomic elements of sublists of the input list.
Given two arrays A and B, reports an array whose dimensions are APPEND(SHAPE OF (A), SHAPE OF (B)) in which each atomic item of the result is computed by applying the dyadic function input to an item of A and an item of B.
1
Reports the number of dimensions of the input.
111
Takes a multidimensional array, and reports an array whose dimensions are reversed (as reported by SHAPE OF). In the case of a two-dimensional array, does the usual transposition of rows and columns.
Reverses the order of the (toplevel) items of the input. If the input is a matrix, this means it reverses the order of the rows, which is a reflection through a horizontal axis, as the ⦵ symbol suggests.
Like MAP, but can take any number of lists as inputs. The lists must all be the same size. The function input must take a number of inputs equal to the number of lists. MULTIMAP calls the function with all the first items, then all the second items, and so on.
cols
Computes a generalized matrix multiplication. In normal matrix multiplication, each cell of the result is computed by multiplying individual numbers within a row of the left input and a column of the right input, and then adding those products. In APL terms this is +.× ("plus dot times") Any dyadic functions can replace addition and multiplication in this algorithm; a common case is ∨.∧ ("or dot and")
111111
Reports the smaller of its two inputs.
This function has two names because there are two ways to understand it. Lisp way: A matrix is a list of rows. This block combines the numbers in each row, producing one value for the entire row. APL way: A matrix is made of vectors. This block takes each column as a vector, and does vector arithmetic on the columns, producing one column as the result.
choicesindexchoices
Reports 1 if the input is positive, 0 if the input is zero, or -1 if the input is negative.
0false
reports 1 divided by its input.
This block reports a random integer between 1 and its input. To roll more than one die, use (for three dice) roll (reshape as 3 items of 6) APL: ?3⍴6 Don't use reshape as 3 items of (roll 6), because that would roll one die and report 3 copies of the same random roll.
Reports True if the input is an APL scalar, i.e., either an atomic (non-list) value, or an array (list of lists) of any depth with only one atomic item, e.g., (list (list (list (3)))).
1
The input must be a value for which SCALAR? reports true, i.e., either an atom or a list of any depth but only one scalar item of item of... etc. This function returns the underlying scalar (number, etc.).
1
Reports the not-and of its inputs, in the form 0 for false, 1 for true.
Reports the not-and of its inputs, in the form 0 for false, 1 for true.
Reports True if the left input is less than or equal to the right input. Reports a Snap! Boolean, not an integer 0 or 1.
Reports True if the left input is greater than than or equal to the right input. Reports a Snap! Boolean, not an integer 0 or 1.
Reports False if its inputs are equal; reports True if its inputs are not equal. The inputs can have any non-list values. (Lists are hyperized.) If the inputs are Booleans (True/False or 1/0), this is also the exclusive-or function.
reports True iff the input is 0 or False.
Reports a Snap! Boolean False if the input is False or 0; reports True otherwise.
0
Turns list of list of ... a single scalar (e.g., ((((x)))) ) into just the scalar. Error if called with anything else.
Make scalar called with non-singleton input
If the input is a positive integer, reports a list of the numbers from 1 to that input. (If the input is 0, reports an empty list.) If the input is a list of positive integers, reports an array with the shape specified by the input (as in ⍴ reshape) in which each item is a list of the indices of that item in the array (so technically the shape has one more dimension than the input, whose size is the size of the input). For list inputs, the size of the result grows very quickly, more or less the factorial of the size of the input. Snap! will not attempt to compute a result bigger than a few million atomic items. ⍳(⍳ 9) will work (≈ 3 million atoms) but ⍳(⍳ 10) will give an error.
If the rank of the left input is one more than the rank of the right input, reports the index of the right input in the left input, or if not found, reports one more than the length of the left input. If the rank of the left input is equal to the rank of the right input, reports a vector of the indices of the items of the right input in the left input (mapping this function over the right input). If the rank of the left input is more than that of the right input by 2 or more, reports a vector, the location of the right input in the left in each dimension. It is an error if the rank of the left input is less than that of the right input.
1result
This isn't an APL function, although it's related to the outer product. It takes any number of lists, and reports a list of all possible tuples with one item from each of the lists. The length of the result is the product of the lengths of the inputs. The result gets very big very quickly. Snap! will refuse to do this computation if the result would be more than a few million atomic items. (crossproduct (⍳(⍳9))) makes about 3 million atomic items; (crossproduct (⍳(⍳10))) gives an error message.
Reports an array of Booleans the same shape as the left input, indicating which of the atoms in the left input appear anywhere in the right input. (The structure of the right input doesn't matter.)
Like append, but: A scalar input is treated as an array the same shape as the other input except that the last item of the shape is 1. If the two inputs are of different ranks, the function is mapped over the larger ranked input. Catenate adds new columns, by appending to each row.
If the input is a nesting of length=1 lists, which APL treats as a scalar (the innermost item) for many purposes, report that innermost scalar. Otherwise, report the input as is. Exposing this block for users is important because Snap! /does not/ treat such a nesting as a scalar, so you might need to use this in translating an APL program to Snap!. (But the functions in the APL library already use this block as needed.)
Reports a vector of indices of the items of the input, in order of the values of the items, so that item (grade up (foo)) of (foo) reports the items in sorted order, smallest to largest. For a matrix, sorts the rows based on their first items, or if those are equal, based on their second items, etc.
Compares two vectors for sorting. Compare first items; if those are equal compare second items; etc.
1111
Reports a vector of indices of the items of the input, in order of the values of the items, so that item (grade down (foo)) of (foo) reports the items in sorted order, largest to smallest. For a matrix, sorts the rows based on their first items, or if those are equal, based on their second items, etc.
The left input must be a vector of Booleans (either Snap! form or APL form); the right input must be an array whose first dimension is equal to the length of the left input. The block reports an array of the same rank as the right input, containing only those items (rows, for a matrix) for which the corresponding Boolean is True (or 1).
The left input must be a vector of Booleans (either Snap! form or APL form); the right input must be an array whose last dimension is equal to the length of the left input. The block reports an array of the same rank as the right input, containing only those items (columns, for a matrix) for which the corresponding Boolean is True (or 1).
Turns a row-wise (in Lisp terminology) function into a column-wise one.
Reverses the order of the columns of the input, which is a reflection through a vertical axis, as the ⏀ symbol suggests.
This function has two names because there are two ways to understand it. Lisp way: A matrix is a list of rows. This block turns it into a list of columns, and combines the numbers in each column, producing one value for the entire column. APL way: A matrix is made of vectors. This block takes each row as a vector, and does vector arithmetic on the rows, producing one row as the result.
Like append, but: A scalar input is treated as a vector of length 1. If the two inputs are of different ranks, the function is mapped over the larger ranked input. Catenate vertically adds new rows, by appending to each column.
A hyperblock version of JOIN. The regular JOIN isn't hyperized because it can accept a list as input, representing it as text.
A positive left input selects the first n items of the right input. A negative left input selects the last abs(n) items of the right input. If the right input is a matrix, a numeric left input selects rows; the left input may also be a two-item vector, in which case the first number is applied to the rows and the second number is applied to the columns. Similarly for higher-dimension arrays.
10valueindex
A positive left input selects all but the first n items of the right input. A negative left input selects all but the last abs(n) items of the right input. If the right input is a matrix, a numeric left input selects rows; the left input may also be a two-item vector, in which case the first number is applied to the rows and the second number is applied to the columns. Similarly for higher-dimension arrays.
0valueindex
Throw an error. Makes a red halo appear around the script that runs it, with the input text shown in a speech balloon next to the script, just like any Snap! error. This is useful to put in the second script of SAFELY TRY after some other instructions to undo the partial work of the first script.
pt:lança o erro _
Reports a sorted version of the list in its first input slot, using the comparison function in the second input slot. For a list of numbers, using < as the comparison function will sort from low to high; using > will sort from high to low.
ca:ordena _ segons criteri _ copy of datasplitmerge11#1#2
1
Takes a (possibly deep) list as input, and reports a human-readable text form of the list (namely, Lisp notation). Will not work on circular lists.
( )
The identity function reports its input.
Takes as input a function of N inputs and N lists. The function is called with item 1 of all the lists as its inputs, with item 2 of all the lists as its inputs, and so on. (The lists should all be the same length.)
Takes a dyadic scalar function as input, and hyperizes it, so that it can take lists as inputs. Don't use on slow functions (this has compiled map calls). Meant for use on primitives.
ab
Computes logarithms in any base. The base is the left input. It's usual in APL that if there's a main data input and some sort of control input, the latter comes on the left. This is because APL syntax, unless you use parentheses, groups computations from right to left. APL has a monadic version of this function that computes natural logs (log to the base e).
Computes the number of combinations of right-input things taken left-input at a time, otherwise known as the elements of Pascal's triangle. This block shares the ! symbol with the monadic factorial function, because the formula for computing this function uses factorials.
The factorial of a positive integer n is the product of the integers from 1 to n. In real APL, the domain of this function is extended beyond integers to compute the gamma function.
Acts just like the function selected from the pulldown menu, but hyperized, so comparing two equal-sized lists reports a list of the same length as the inputs, with the results of item-by-item comparisons.
﹦ ≠ identical to and or is _ a _?
Report a list with left-input random integers in the range 1 to right-input. No number appears more than once in the result.
Reports the greatest common divisor of its inputs. If the inputs are values in {0,1} then this is equivalent to the logical OR of the values, with 0=False, 1=True. Hence the APL symbol ∨. Also accepts Snap! Booleans as inputs.
Reports the least common multiple of its inputs. If the inputs are values in {0,1} then this is equivalent to the logical AND of the values, with 0=False, 1=True. Hence the APL symbol ∧. Also accepts Snap! Booleans as inputs.
Reports 1 if the input is False or 0; otherwise reports 0.
Reports its input. This is useful to fit a value into a different-type input slot, e.g., number into list slot.
6,1,3,9,8,4,8,2,5,43,4,4,3,10,2,7,7,9,47,1,1,4,5,7,10,8,4,54,3,5,6,6,1,5,5,3,102,9,3,3,6,6,3,5,8,22,9,10,2,1,4,2,10,1,94,8,9,10,7,2,9,1,9,67,8,8,5,3,9,9,4,10,58,9,6,7,1,9,5,9,3,41,7,1,9,10,5,10,6,5,7