············@googlemail.com writes:
> Does anyone know of a suffix tree or suffix array implementation in CL?
I didn't know any, but a quick browsing of wikipedia, and some little
suggar burning by a few nerons gives:
(defun suffix-array (string)
(map 'vector (function car)
(sort
(loop
:for i :from 0 :below (length string)
:collect (cons i (make-array (- (length string) i)
:element-type (array-element-type string)
:displaced-to string
:displaced-index-offset i)))
(function string<=) :key (function cdr))))
C/USER2[919]> (suffix-array "abracadabra")
#(10 7 0 3 5 8 1 4 6 9 2)
Of course, you need a few free neurons to work it out...
--
__Pascal Bourguignon__ http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.
············@googlemail.com writes:
> Does anyone know of a suffix tree or suffix array implementation in CL?
Also, three years ago, rif published his implementation of McCreight's
O(n) suffix-tree algorithm in cll:
http://groups.google.com/group/comp.lang.lisp/msg/d0828f590a78e958
http://paste.lisp.org/display/34390
--
__Pascal Bourguignon__ http://www.informatimago.com/
PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.