Created
August 1, 2012 07:25
-
-
Save danlei/3224534 to your computer and use it in GitHub Desktop.
Syntactic motif offsets (Lisp baseline)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun indices (input-file output-file) | |
(with-open-file (in input-file :direction :input) | |
(with-open-file (out output-file :direction :output | |
:if-exists :supersede | |
:if-does-not-exist :create) | |
(loop with previous-field = nil | |
for index from 0 | |
for field = (read in nil nil) | |
while field | |
if (not previous-field) | |
do (format out "0") | |
else if (<= field previous-field) | |
do (format out " ~w" index) | |
do (setq previous-field field))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment