Mark,
Simply expanding the list to
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 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"
Work well - this is thus base 62, and is certainly space saving, for example
982545133223 decimal = HIUVFMl base 62
12 digit decimal down to a 7 digit base 62
87982545133223 decimal = Oyysz4yN base 62
14 digit decimal down to a 8 digit base 62
99,999,999,999,999,999 decimal = 7O044qYiZc base 62
17 digit decimal down to a 10 digit base 62
This is a saving of 7 bytes per number, a lot of bytes if you did have
99,999,999,999,999,999
numbers.
It would be nice if we had a filter Operator for this!
great work Mark
Regards
Tony
On Sunday, October 13, 2019 at 2:55:44 AM UTC+11, Mark S. wrote:
>
> I checked the code. I think you should just be able to extend the symbol
> list. I couldn't see anywhere where I had
> used case-sensitive code. I think you would want to avoid any characters
> that have special meaning in TW,
> including ' " [ ] { } |
>
> Let us know!
>
> On Friday, October 11, 2019 at 10:30:34 PM UTC-7, TonyM wrote:
>>
>> 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/62d05bc5-ab47-472b-9759-0d07e26cffa8%40googlegroups.com.