diff options
author | Hans Hagen <pragma@wxs.nl> | 2016-11-24 12:55:35 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-11-24 12:55:35 +0100 |
commit | f4d0ad2ba2c4ca5bfae469650e535fd46749b3f4 (patch) | |
tree | 71f81a4992ab89b86a054bd608e49d9093389481 /metapost/context/base/mpiv/mp-mlib.mpiv | |
parent | f4ff686750ca9405662c7615e9c4b04685b5be5c (diff) | |
download | context-f4d0ad2ba2c4ca5bfae469650e535fd46749b3f4.tar.gz |
2016-11-24 12:10:00
Diffstat (limited to 'metapost/context/base/mpiv/mp-mlib.mpiv')
-rw-r--r-- | metapost/context/base/mpiv/mp-mlib.mpiv | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index 39d74b352..0c7dddf4c 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -1625,3 +1625,32 @@ enddef ; def comment expr str = special "metapost.comment[[" & str & "]]" ; enddef ; + +% This overloads a dummy: + +vardef uniquelist(suffix list) = + % this can be optimized by passing all values at once and returning + % a result but for now this is ok .. we need an undef foo + save i, j, h ; + if known lis[0] : + i := 0 ; + j := -1 ; + else : + i := 1 ; + j := 0 ; + fi ; + h := lua.mp.newhash() ; + forever : + exitif unknown list[i] ; + if not lua.mp.inhash(h,list[i]) : + j := j + 1 ; + list[j] := list[i] ; + lua.mp.tohash(h,list[i]) ; + fi ; + i := i + 1 ; + endfor ; + for n = j+1 step 1 until i-1 : + dispose(list[n]) + endfor ; + lua.mp.disposehash(h) ; +enddef ; |