Mark, If want to expand this to base 36+26 = 62 to add lowercase can I just extend the arrays, or is more involved?
As mentioned before such a base 62 with readable symbols would use far less bytes than base 10, especially if I used it to create a tiddler serial number. Since coming up with a method to automatically store a unique serial number in a tiddler field I have realised it could be very helpful to do more in tiddlywiki, - Build compound tiddlers - Edit a tiddler displayed reliably in another - Enable tiddler rename (also helped by relink) - Enable subtiddlers to any tiddler (Rename reliable) - and more The most common function in such a situation would be to add one, increment the last serial number. I imagine doing this to a decimal number and converting it to base 62 would be the best and easiest unless there is a simple way to add 1 to any base number. I love algorithms and seeing how people tackle them. *Thanks for sharing.* Regards Tony On Saturday, October 12, 2019 at 11:38:35 AM UTC+11, Mark S. wrote: > > > For converting back to base 10. Just barely tested. Seems to work. > > Usually converting from base x to base 10 would be easier than the other > way around. But > the lack of a power function and an easy way to index an array meant that > this was > actually harder, somehow. > > > \define base-deconverter(num,exp,result:"") > <$list filter="[<__num__>split[]last[]]" variable="sym"> > <$list filter="[<__num__>split[]butlast[1]join[]]" variable="next"> > <$list filter="[enlist:raw<syms>allbefore<sym>count[]]" variable="num"> > <$list filter="[enlist:raw<__exp__>product[]multiply<num>add<__result__>]" > variable="result"> > <$list filter="[<__exp__>addsuffix[ ]addsuffix<base>]" variable="exp" > > <$list filter="[<next>!is[blank]]" emptyMessage=<<result>>> > <$macrocall $name="base-deconverter" num=<<next>> exp=<<exp>> result=<< > result>> /> > </$list> > </$list> > </$list> > </$list> > </$list> > </$list> > \end > > \define tobase10(num,base) > <$vars > syms="0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X > Y Z" > base=<<__base__>> > > > <<base-deconverter $num$ "1" >> > </$vars> > \end > > <<tobase10 133 5>> > > > > > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d9bc4de9-99a4-4fb8-b859-68399acf51f6%40googlegroups.com.

