Skip to content

Portal: Instructions

Haoxi Zhan edited this page Dec 11, 2013 · 5 revisions

Utils behind Instructions

ensure-list

Ensure the input to be a list. If it has been a sequence, do nothing; otherwise, return a list of it

print-return

Print the input and return it.

keep-number-reasonable

If a number is out of range (defined by max-number-magnitude and min-number-magnitude), set it to the max / min value.

count-points

Count the number of points in a tree. Each atom and each pair of parentheses is regard as one point.

truncate

Truncate numbers to integers. For example, 100.5 would be truncated to 100 and -134.2 would be truncated to 134

subst

subst [A B C] would substitute all Bs in C with A

contains-subtree

Returns true if the first argument contains the second argument as a subtree

containing-subtree

Returns the smallest subtree of the first argument which contains the second argument

all-items

Returns a list of all items in the argument. Duplicates would be contained. Both sublists and atoms are considered as items.

not-lazy

If it is a list, return a non-lazy version of it. If it isn’t a list, return it as a list.

Clone this wiki locally