Burrows–Wheeler transform: Difference between revisions

→‎{{header|TXR}}: Shorter code, particularly ibwt; sanity check in bwt.
(→‎{{header|TXR}}: New section.)
(→‎{{header|TXR}}: Shorter code, particularly ibwt; sanity check in bwt.)
Line 2,667:
 
<syntaxhighlight lang="txrlisp">(defun bwt (str)
(let*if ((seofcontains eof `@str\xDC00`)
(error "~s: input may not (ncontain (len~a" %fun% seof)eof))
(flow (collect-eachlet* ((iseof 0..n`@str@eof`))
(flow (collect-each ((i 0..(len seof)))
(rot seof i))
sort
Line 2,675 ⟶ 2,676:
 
(defun ibwt (str)
(let* ((nch (lentuples 1 str))
(row (vectorsort n ""ch)))
(dotimes (i n(pred (len str)))
(setupd [row i] (mkstringmapcar 0append ch) nsort))
[(find-if (op ends-with "\xDC00"eof) row) 0..-1]))</syntaxhighlight>
(dotimes (i n)
(each ((c str)
(j 0))
(set [row j] `@c@[row j]`))
(nsort row))
[(find-if (op ends-with "\xDC00") row) 0..-1]))</syntaxhighlight>
 
At the REPL:
543

edits