# HG changeset patch # User Steve Losh # Date 1790955579 14400 # Node ID 0711b20b976c3a27a9c6217519b63013003f8c6b # Parent 9653a73b90b6cbbe43febfe8def0c0cf111f8d9b Update documentation diff -r 9653a73b90b6 -r 0711b20b976c DOCUMENTATION.markdown --- a/DOCUMENTATION.markdown Fri Oct 02 11:39:24 2026 -0400 +++ b/DOCUMENTATION.markdown Fri Oct 02 11:39:39 2026 -0400 @@ -18,56 +18,6 @@ -## Package `LOSH.ASTAR` - -A★ search in a handy package. - -### `ASTAR` (function) - - (ASTAR &KEY START NEIGHBORS GOALP COST HEURISTIC TEST LIMIT GET-SEEN SET-SEEN) - -Search for a path from `start` to a goal using A★. - - The following parameters are all required: - - * `start`: the starting state. - - * `neighbors`: a function that takes a state and returns all states reachable - from it. - - * `goalp`: a predicate that takes a state and returns whether it is a goal. - - * `cost`: a function that takes two states `a` and `b` and returns the cost - to move from `a` to `b`. - - * `heuristic`: a function that takes a state and estimates the distance - remaining to the goal. - - * `test`: an equality predicate for comparing nodes. It must be suitable for - passing to `make-hash-table`. - - If the heuristic function is admissable (i.e. it never overestimates the - remaining distance) the algorithm will find the shortest path. If you don't - have a decent heuristic, just use `(constantly 0)` to degrade to Dijkstra. - - Note that `test` is required. The only sensible default would be `eql`, but - if you were using states that need a different predicate and forgot to pass it - the algorithm would end up blowing the heap, which is unpleasant. - - The following parameters are optional: - - * `limit`: a maximum cost. Any paths that exceed this cost will not be - considered. - - * `set-seen`: a function that takes a state and a cost, and records it. - If not provided a hash table will be used, but sometimes (depending on what - your states are) it can be faster to store visited nodes more efficiently. - - * `get-seen`: a function that takes a state and retrieves the stored cost, or - `nil` if the state has not been seen. - - - ## Package `LOSH.ARRAYS` Utilities related to arrays. @@ -229,6 +179,56 @@ +## Package `LOSH.ASTAR` + +A★ search in a handy package. + +### `ASTAR` (function) + + (ASTAR &KEY START NEIGHBORS GOALP COST HEURISTIC TEST LIMIT GET-SEEN SET-SEEN) + +Search for a path from `start` to a goal using A★. + + The following parameters are all required: + + * `start`: the starting state. + + * `neighbors`: a function that takes a state and returns all states reachable + from it. + + * `goalp`: a predicate that takes a state and returns whether it is a goal. + + * `cost`: a function that takes two states `a` and `b` and returns the cost + to move from `a` to `b`. + + * `heuristic`: a function that takes a state and estimates the distance + remaining to the goal. + + * `test`: an equality predicate for comparing nodes. It must be suitable for + passing to `make-hash-table`. + + If the heuristic function is admissable (i.e. it never overestimates the + remaining distance) the algorithm will find the shortest path. If you don't + have a decent heuristic, just use `(constantly 0)` to degrade to Dijkstra. + + Note that `test` is required. The only sensible default would be `eql`, but + if you were using states that need a different predicate and forgot to pass it + the algorithm would end up blowing the heap, which is unpleasant. + + The following parameters are optional: + + * `limit`: a maximum cost. Any paths that exceed this cost will not be + considered. + + * `set-seen`: a function that takes a state and a cost, and records it. + If not provided a hash table will be used, but sometimes (depending on what + your states are) it can be faster to store visited nodes more efficiently. + + * `get-seen`: a function that takes a state and retrieves the stored cost, or + `nil` if the state has not been seen. + + + ## Package `LOSH.BASE` A few utilities re-exported from Alexandria, plus some other basic stuff. @@ -256,6 +256,64 @@ +## Package `LOSH.BIOINFORMATICS` + +Utilities related to bioinformatics. + +### `N50` (function) + + (N50 DATA &KEY (KEY #'IDENTITY)) + +Return the N50 statistic of `data`. + + `key` will be called on each element of `data` and should return the length + of each datum. + + An empty `data` will return an N50 of `0`. + + Examples: + + (n50 (list 2 3 4 5 6 7 8 9 10)) + ;; => 8 + + (n50 (vector "ACTACCAT" + "CAGAC" + "GCTT" + "CCCCCCC" + "CCAACCAAA" + "CA") + :key #'length) + ;; => 7 + + + +### `N90` (function) + + (N90 DATA &KEY (KEY #'IDENTITY)) + +Return the N90 statistic of `data`. + + `key` will be called on each element of `data` and should return the length + of each datum. + + An empty `data` will return an N90 of `0`. + + Examples: + + (n90 (list 2 3 4 5 6 7 8 9 10)) + ;; => 4 + + (n90 (vector "ACTACCAT" + "CAGAC" + "GCTT" + "CCCCCCC" + "CCAACCAAA" + "CA") + :key #'length) + ;; => 4 + + + ## Package `LOSH.BITS` Utilities for low-level bit stuff. @@ -987,6 +1045,12 @@ +### `HEXDUMP` (function) + + (HEXDUMP BYTES) + +Dump `bytes` to standard out by shelling out to `xeh`. + ### `PHR` (function) (PHR)