Jonathan Sauer wrote: > Hello Hans, > >>> Caveat: In TeX, braces can be used to hide the <delimiter>; this is >>> not possible in the above code. I plan to code a >>> "string.findOutsideBraces" function to handle braces correctly, but > I >>> wonder if this should not be a library routine. >> the embedded libaries and extensions are kept to the minimum, >> if only because we want to avoid endless discussions about >> what could go in there; lua is fast enough anyway; concerning >> braces .. watch the %b option on expressions, can be handy >> for nested braces > > Right. I am still learning Lua and had known about patterns, but not > about %b. That indeed looks promising. I will look into it.
simple example ... \def\sortedsequence#1#2{\directlua 0 { do local sep = "\luaescapestring{#1}" local str = "\luaescapestring{#2}" local tab = { } for s in string.gmatch(str,"([^"..sep.."]+)") do tab[\string ##tab+1] = s end table.sort(tab) tex.sprint(table.concat(tab,sep)) end }} \sortedsequence{,}{qq,aa,cc,bb,ee,xx} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________