anchor.diff:  (in-package :conllu.editor)
   
   (defun conlluedit (sentences transformations)
  -  (mapcar #'(lambda (sentence)
  -	      (all-transformations sentence transformations 1))
  -	  sentences)
  -  t)
  +  (reduce #'(lambda (acumulated-results sentence)
  +	      (let* ((sent-id (sentence-id sentence)) 
  +		     (results (apply-transformations sentence sent-id transformations)))
  +		(if results
  +		    (cons (cons sent-id results) acumulated-results)
  +		    acumulated-results)))
  +	  sentences :initial-value nil))
   
   ;; part 0
   
  -(defun all-transformations (sentence transformations index)
  -  (when transformations
  -    (when (apply-transformation sentence (first transformations) index)
  -      (all-transformations sentence (rest transformations) (1+ index)))))
  -
  -
  -(defun apply-transformation (sentence transformation transform-index)
  -  (let* ((transformation (transformation transformation))
  -	 (definitions    (getf transformation :definitions))
  -	 (relations      (getf transformation :relations))
  -	 (actions        (getf transformation :actions))
  +(defun apply-transformations (sentence sent-id rules &optional (index 1) acumulated-results)
  +  (if rules
  +      (let ((results (apply-transformation sentence sent-id (first rules) index)))
  +	(when (first results)
  +	  (apply-transformations sentence sent-id (rest rules) (1+ index)
  +				 (cons (cons index (rest results)) acumulated-results))))
  +      acumulated-results))
  +
  +
  +(defun apply-transformation (sentence sent-id rules rule-index)
  +  (let* ((definitions    (definitions (first rules)))
  +	 (relations      (relations (nth 1 rules)))
  +	 (actions        (actions (nth 2 rules)))
   	 (tokens         (sentence-tokens sentence))
   	 (nodes          (node-matchers tokens definitions)))
       (when nodes
  
positive.code: 
  ;; part 5
  
  (defun all-result-actions (sets tokens actions &optional (result-actions nil))
    (cond ((null actions)
  	 (cons t (reverse result-actions))) 
  	((first actions)
  	 (all-result-actions sets tokens (rest actions)
  			     (cons (result-action sets tokens (first actions)) 
  				   result-actions)))
  	(t
  	 (cons nil (reverse result-actions)))))
  
  (defun result-action (sets tokens action)
    (let ((result-tokens (assoc-tokens (nth 1 action) tokens sets))
  	(field (nth 2 action)))
      (list field result-tokens
  	  (mapcar (cond ((first action)
  			 #'(lambda (token)
  			     (get-field (nth 4 action)
  					(nth (1- (rest (assoc (nth 3 action) sets)))
  					     tokens))))
  			((nth 3 action)
  			 #'(lambda (token)
  			     (nth 4 action)))
  			(t
  			 #'(lambda (token)
  			     (eval `(funcall ,(nth 4 action) ,(get-field field token))))))
  		  result-tokens))))
  
  (defun assoc-tokens (value tokens sets)
    (reduce #'(lambda (result-tokens set)
  	      (if (= value (first set))
  		  (cons (nth (1- (rest set)) tokens) result-tokens)
  		  result-tokens))
  	  sets :initial-value nil))
  
  
  ;; part 6	      
  
  (defun examine-actions (final-actions &optional (not-first nil))
    (if final-actions
        (let ((result-action (first final-actions)))
  	(when (and (find (first result-action)
  			 '(id form lemma upostag feats feats head deprel deps misc)
  			 :test #'string=)
  		   (not (string= 'nil (first (nth 2 result-action)))))
  	  (examine-actions (rest final-actions) t)))
        not-first))
  
  (defun apply-action (result-action)
    (let ((field (first result-action)))
      (mapcar (lambda (token string-value)
  	      (let ((value (if (or (string= field 'id) (string= field 'head))
  			       (parse-integer string-value)
  			       string-value)))
  		(setf (slot-value token (itern field "CL-CONLLU"))
  		      value)))
  	    (nth 1 result-action) (nth 2 result-action))))
  
  
negative.code: 			   actions :initial-value nil))))
  
  (defun action (expression)
    (unless (string= (first expression) 'last)
      (if (= (length expression) 5)
  	(list t   (nth 1 expression) (nth 3 expression) (nth 2 expression) (nth 4 expression))
  	(list nil (nth 1 expression) (nth 2 expression) (stringp nth-3) (nth 3 expression)))))
  
  
  (defun get-field-value (field token)
    (let ((value (slot-value token (intern (symbol-name field) "CL-CONLLU"))))
      (if (integerp value)
  	(write-to-string value)
  	value)))
  
  
  (defun normalize-shorthand (expression operator)
    (if (string= (first expression) '>)
        (nth 1 (reduce #'(lambda (result node-2)
  			 (list node-2
  			       (cons `(,operator ,node-2 ,(first result) head id)
  