elixush v0.0.2 Elixush.Util

Summary

Functions

Returns a subtree of tree indexed by point-index in a depth first traversal

computes the next row using the prev-row current-element and the other seq

If tree contains subtree at any level then this returns the smallest subtree of tree that contains but is not equal to the first instance of subtree. For example, contining-subtree([b [c [a]] [d [a]]], [a]]) => [c [a]]. Returns nil if tree does not contain subtree

Returns true if tree contains subtree at any level. Inefficient but functional implementation

Returns the number of paren pairs in tree

Returns the number of points in tree, where each atom and each pair of parentheses counts as a point

really make-list-if-not-seq, but close enough for here

Returns a copy of tree with the subtree formerly indexed by point_index (in a depth-first traversal) replaced by new_subtree

Returns a version of n that obeys limit parameters

Levenshtein Distance - http://en.wikipedia.org/wiki/Levenshtein_distance In information theory and computer science, the Levenshtein distance is a metric for measuring the amount of difference between two sequences. This is a functional implementation of the levenshtein edit distance with as little mutability as possible. Still maintains the O(n*m) guarantee

Like postwalk, but only for lists

Like postwalk-replace, but only for lists

Prints the provided thing and returns it

If thing is a literal, return its type -- otherwise return false

If a number, rounds float f to n decimal places

Returns the given list but with all instances of that (at any depth) replaced with this. Read as 'subst this for that in list'

Like walk, but only for lists

Functions

code_at_point(tree, point_index)

Returns a subtree of tree indexed by point-index in a depth first traversal.

compute_next_row(prev_row, current_element, other_seq, pred)

computes the next row using the prev-row current-element and the other seq

containing_subtree(tree, subtree)

If tree contains subtree at any level then this returns the smallest subtree of tree that contains but is not equal to the first instance of subtree. For example, contining-subtree([b [c [a]] [d [a]]], [a]]) => [c [a]]. Returns nil if tree does not contain subtree.

contains_subtree(tree, subtree)

Returns true if tree contains subtree at any level. Inefficient but functional implementation.

count_parens(tree)

Specs

count_parens(Enum.t) :: integer

Returns the number of paren pairs in tree

count_points(tree)

Specs

count_points(Enum.t) :: integer

Returns the number of points in tree, where each atom and each pair of parentheses counts as a point.

ensure_list(thing)

really make-list-if-not-seq, but close enough for here

insert_code_at_point(tree, point_index, new_subtree)

Returns a copy of tree with the subtree formerly indexed by point_index (in a depth-first traversal) replaced by new_subtree.

keep_number_reasonable(n)

Specs

keep_number_reasonable(number) :: number

Returns a version of n that obeys limit parameters.

levenshtein_distance(a, b, p)

Levenshtein Distance - http://en.wikipedia.org/wiki/Levenshtein_distance In information theory and computer science, the Levenshtein distance is a metric for measuring the amount of difference between two sequences. This is a functional implementation of the levenshtein edit distance with as little mutability as possible. Still maintains the O(n*m) guarantee.

postwalklist(f, form)

Like postwalk, but only for lists

postwalklist_replace(smap, form)

Like postwalk-replace, but only for lists

recognize_literal(thing)

If thing is a literal, return its type -- otherwise return false.

round_to_n_decimal_places(f, n)

If a number, rounds float f to n decimal places.

some(enumerable, fun)
subst(this, that, lst)

Returns the given list but with all instances of that (at any depth) replaced with this. Read as 'subst this for that in list'.

walklist(inner, outer, form)

Like walk, but only for lists.