avoid redundant positions;
authorwenzelm
Wed, 13 Dec 2017 16:42:02 +0100
changeset 67195 6be90977f882
parent 67194 1c0a6a957114
child 67196 eb29f4868d14
avoid redundant positions;
src/Pure/Thy/latex.ML
--- a/src/Pure/Thy/latex.ML	Wed Dec 13 16:18:40 2017 +0100
+++ b/src/Pure/Thy/latex.ML	Wed Dec 13 16:42:02 2017 +0100
@@ -57,12 +57,16 @@
 fun output_positions file_pos texts =
   let
     fun position (a, b) = enclose "%:%" "%:%" (a ^ "=" ^ b);
+    fun add_position p positions =
+      let val s = position (apply2 Value.print_int p)
+      in positions |> s <> hd positions ? cons s end;
+
     fun output (Text (s, pos)) (positions, line) =
           let
             val positions' =
               (case Position.line_of pos of
                 NONE => positions
-              | SOME l => position (apply2 Value.print_int (line, l)) :: positions);
+              | SOME l => add_position (line, l) positions);
             val line' = fold_string (fn c => fn n => if c = "\n" then n + 1 else n) s line;
           in (positions', line') end
       | output (Block body) res = fold output body res;