PSC Code Manual

util/comparison.lsp [src]

Functions related to comparisons

Functions

Function signature Description
(<f a b fuzz) Returns nil unless A is less than B by FUZZ
(=f a b fuzz) Return nil unless A and B are equal within FUZZ
(>f a b fuzz) Returns nil unless A is greater than B by FUZZ
(identity x) Returns X.
(or* branches) Returns the first non-nil element of BRANCHES.
(sort-by func cmp) Returns a lambda for processed sorting
(sort-by-key key cmp) Returns a lambda for sorting a data list by the value of KEY
(sort-stairland a b) Sorts a part of stair/landing enames in ascending order.
(sort-strings-asc a b) A comparison function that accounts for length when sorting strings

(<f a b fuzz)

Returns nil unless A is less than B by FUZZ

(=f a b fuzz)

Return nil unless A and B are equal within FUZZ

(>f a b fuzz)

Returns nil unless A is greater than B by FUZZ

(identity x)

Returns X.

TESTS:
(= (IDENTITY 'X) 'X)

(or* branches)

Returns the first non-nil element of BRANCHES.

or* doesn't eval the branches, so doesn't do short-circuiting.

VARS:
(BRANCHES nil (LISTP BRANCHES))

TESTS:
(= (OR* '(nil 1 2)) 1)
(= (OR* '(nil nil)) nil)

(sort-by func cmp)

Returns a lambda for processed sorting

The result of this function is a lambda suitable for passing to vl-sort. CMP should be a
comparison function of 2 arguments that would normally be passed to vl-sort. FUNC should
be a function of 1 argument that will be used to process both arguments to CMP.

Returns the equivalent of '(lambda (a b) (CMP (FUNC a) (FUNC b))).

VARS:
(FUNC (SYM LIST SUBR USUBR))
(CMP (SYM LIST SUBR USUBR))

TESTS:
(EQUAL (SORT-BY 'CAR '<) '(LAMBDA (A B) (< (CAR A) (CAR B))))

(sort-by-key key cmp)

Returns a lambda for sorting a data list by the value of KEY

The result of this function is a lambda suitable for passing to vl-sort. CMP should be a
comparison function of 2 arguments that would normally be passed to vl-sort. KEY should be
a key from the data list as a string.

VARS:
(KEY STR)
(CMP (SYM LIST SUBR USUBR))

(sort-stairland a b)

Sorts a part of stair/landing enames in ascending order.

This function is designed to be passed to vl-sort. The resulting sort order will sort by
elevation and put landings in front of stairs at the same level. Multiple landings at the
same level are not considered.

(sort-strings-asc a b)

A comparison function that accounts for length when sorting strings

Pass as comparison argument to vl-sort.