Discussion:
[tw] [TW5] Updated: rpn – Plugin for calculations, random numbers and text concatenation
Thomas Elmiger
2017-08-14 15:50:32 UTC
Permalink
Hi all

After seeing some interest and other applications (Mat’s GRAPHS) using my
little plugin for calculations, I showed my little pony some new tricks.

Besides much better structured code in JS I am especially content with
wikification of input (operands) and output (concatenated text) as well as
number formatting using locale standard (see
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
for more info).

Here is in short what rpn can do for you in version 0.6.2:

===

rpn is a lightweight Javascript macro for basic math operations in
TiddlyWiki. It is inspired by formerly popular calculators using Reverse
Polish Notation (see Wikipedia
<https://en.wikipedia.org/wiki/Reverse_Polish_notation> for more info).


<<rpn 50 2.5 * 2 p>> output: 125.00

- takes two operands (*a* and *b*) as input – this may be macros or
transclusions
- operands are sent through a simplified wikify
<http://tiddlywiki.com/#WikifyWidget> function before calculation
starts
- use *pi* to get π (Math.PI)
- basic operations: +, -, /, *
- advanced operations: modulus (%) and rounding (optional: Math.floor
or Math.ceil)
- output formatting
- limit digits after comma (*decimals*), force *precision* display
with *precision:"p"* (.toPrecision)
- *locale* formatting (.toLocaleString)
- string concatenation (&)
- the resulting string is sent through the internal wikify
<http://tiddlywiki.com/#WikifyWidget> function
- random numbers in a range from a to b with *precision:"r"* (including
both a and b)

Installation


The plugin available on https://tid.li/tw5/plugins.html includes some
documentation. Additional test and demos are on
https://tid.li/tw5/hacks.html#rpnTest.


===


As always: Make a backup first and let me know how it goes.


Suggestions for optimisations are always welcome but might need some time.


Happy calculations,

Thomas
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/31e195c4-42bb-4517-ab29-0557c9ca37c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-14 16:25:23 UTC
Permalink
Ciao Thomas

Did you know that a "Pony" is £25 British Pounds in Cockney rhyming slang
(also a "Macaroni" is £25), whilst an "Apple Core" (a score) is only £20 ?
Well worth it for your doings.

London East End
Josiah
... I showed my little pony some new tricks.
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/126adc24-1947-453f-9a1a-58d7a69c1be8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 15:16:57 UTC
Permalink
Ciao Thomas

Originally I wasn't really interested in RPN because I'm still looking for
something simple that can add up a column in a table without having to have
a Tiddler per row.

However RPN its growing on me as a way to do simple calculations. *Obvious
applications are, for instance, a measures convertor* (°F -> °C; Euros to
Dollars etc)

Could it, for instance, calculate the weight of your pony? :-)

Just for fun here is the formula for estimating the weight of a pony ...

Pony Weight in Kgs = (heart-girth2 cms x length-from-shoulder-to-tip-of-buttocks
cms) / 11,880

Note: the small "2" on "heart-girth" means "squared".

Best wishes
Josiah
Post by Thomas Elmiger
I showed my little pony some new tricks.
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b70a5912-69c5-4fb3-986a-b2de27efa677%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 15:47:57 UTC
Permalink
Ciao Thomas

A lot of British, Australians & Americans & others still think in Imperial
Measures.

One of the most mutually confusing things between Brits & mainland
Europeans is many British still weigh themselves in "Stones" and pounds,
not Kilos.

Can RPN provide a converter back and forth between British Stones and Euro
Kilos? What would the solution look like?

Here is a test case...

Joe Bloggs, British, weighs 10 Stone, 3.5 Pounds.

What weight is Joe Bloggs in Kilos? ... given ...

1 Stone = 14 Pounds
1 Kilo = 2.20462 Pounds

Love to the pony. Happy weighty calculations :-)
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/023f2430-a5e0-453a-b61a-9f12e878f477%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thomas Elmiger
2017-08-16 19:14:11 UTC
Permalink
Ciao Josiah and Mark

Yeehaw! – <https://en.wikipedia.org/wiki/Yeehaw> Your feedback’s worth in
stones would be enough to build a house! Thank you very much, this will at
least improve my docs by several miles ;–)

Easy things first. Here’s a unidirectional converter for two units in three
lines:

The metric weight of <$edit-text tiddler="$:/temp/british-weight-converter"
field="text" tag="input" size="3"/> ''kg'' is equal to:

<$macrocall $name=rpn a={{$:/temp/british-weight-converter}} b=2.20462
operation=* locale=en-GB/> pounds

<$macrocall $name=rpn a={{$:/temp/british-weight-converter}} b=<<rpn 2.20462
14 />> operation=* decimals=3 locale=en-GB/> stones

Josiah, it would be a great success for me personnally if you would build a
converter for the other direction or even a pony weight estimator based on
this example.
Is your test case pointing to the fact, that instead of fractions of
stones, the calculater should show pounds? That would require some
additional lines of code 


Happy conversions,
Thomas

---

''Important!'' Shortcut macro calls in <<syntax>> are not dynamic and get
updated only through re-rendering e.g. when a tiddler is saved or loaded:

<<rpn {{$:/temp/british-weight-converter}} 2.20462 * locale:en-GB>> pounds
Post by @TiddlyTweeter
One of the most mutually confusing things between Brits & mainland
Europeans is many British still weigh themselves in "Stones" and pounds,
not Kilos.
Can RPN provide a converter back and forth between British Stones and Euro
Kilos? What would the solution look like?
Here is a test case...
Joe Bloggs, British, weighs 10 Stone, 3.5 Pounds.
What weight is Joe Bloggs in Kilos? ... given ...
1 Stone = 14 Pounds
1 Kilo = 2.20462 Pounds
Love to the pony. Happy weighty calculations :-)
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/93f64d33-63f4-4bf5-84bb-a0b43d47bb34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-17 09:31:13 UTC
Permalink
Ciao Thomas (& Mark S.) ...
Post by Thomas Elmiger
Is your test case pointing to the fact, that instead of fractions of
stones, the calculator should show pounds?
In actual verbal usage Brits are more likely to say "I'm 10 stone and
a-half" or "I'm 10 stone and a-quarter"" than "I'm 10 stone and 7 pounds"
or "I'm 10 stone and 3 and a-half pounds". Either with pounds, or without,
would work. The user could figure it out.

The decimal places for weight, both straight pounds & stones practically
would be better rounded to one place on this. Verbal expression of weight
wouldn't bother with fractional values beyond that.

For North Americans having weight, as you do, in pounds is spot-on. They
don't use stones at all.
Post by Thomas Elmiger
.... Josiah, it would be a great success for me personally if you would
build a converter for the other direction ...
Eeek! *Give me a week*.
Post by Thomas Elmiger
Easy things first. Here’s a unidirectional converter for two units in
The metric weight of <$edit-text tiddler=
"$:/temp/british-weight-converter" field="text" tag="input" size="3"/> ''
<$macrocall $name=rpn a={{$:/temp/british-weight-converter}} b=2.20462
operation=* locale=en-GB/> pounds
<$macrocall $name=rpn a={{$:/temp/british-weight-converter}} b=<<rpn
2.20462 14 />> operation=* decimals=3 locale=en-GB/> stones
TchÃŒss
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/31c1b861-f522-47c4-9844-2536fcc10bca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-19 10:47:59 UTC
Permalink
Ciao Thomas

*Surprisingly, I found it not too difficult*. Result below ...

Then I attempted a Celsius to Fahrenheit conversion and failed. It needs
two steps and I couldn't work out how to do that.

The °C -> °F is: T(°F) = T(°C) × 1.8 + 32

Love to the pony. Best wishes,
Josiah
Post by @TiddlyTweeter
Post by Thomas Elmiger
.... Josiah, it would be a great success for me personally if you would
build a converter for the other direction ...
Eeek! *Give me a week*.
''Stones''

<$edit-text tiddler="$:/temp/stone-converter" field="text" tag="input" size=
"4"/> stones = <$macrocall $name=rpn a={{$:/temp/stone-converter}} b=6.35029
operation=* decimals=2 /> kilograms = <$macrocall $name=rpn a={{$:/temp/
stone-converter}} b=14 operation=* decimals=2 locale=en-GB/> pounds
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f5128f34-c933-4387-bc6e-eb7f23e68a2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2017-08-19 13:52:50 UTC
Permalink
Post by @TiddlyTweeter
Then I attempted a Celsius to Fahrenheit conversion and failed. It needs
two steps and I couldn't work out how to do that.
The °C -> °F is: T(°F) = T(°C) × 1.8 + 32
Maybe you guys are doing some kind of challenge with special restriction
rules, but otherwise I think it can be done like so:


\define CtoF(C) <$macrocall $name=rpn a=<<rpn $C$ 1.8 *>> b=32 operation=+
/>


This should work (didn't test it) because Thomas made the rpn macro
conveniently wikifies the output. Otherwise, one would have to split out
that inner macro call and use a surrounding setwidget or wikifywidget to
assignt a variable with the value of the split out macro... and only then
use that variable in the macrocallwidget.


<:-)
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b9144b08-44bb-4a7a-afd3-ab62384083da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-19 13:55:09 UTC
Permalink
Ciao Thomas

Did you know there are 33.814022558919 PONY to the liter?
https://www.convertunits.com/from/pony/to/liter

Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/2f743f9f-c24e-4d7e-9f18-26eba7ee9915%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thomas Elmiger
2017-08-19 21:51:56 UTC
Permalink
Ciao Josiah and Mat

Both your solutions work as expected. Great!

Here’s a reward for Josiah for doing his homework (requires my EditorCounter
<https://tid.li/tw5/plugins.html#%24%3A%2Fplugins%2Ftelmiger%2FEditorCounter>):


\define charLimit() 140
\define charCount(tid) <$editor-counter tiddler="""$tid$"""/>

''Text''

<$edit-text tiddler="$:/temp/text-to-count-down" field="text" rows="3"
minHeight="3em" autoHeight="yes" class="te-vt-note-field"/>

<$reveal type=nomatch state="$:/temp/text-to-count-down" text="">
<$wikify name=count text='<$macrocall $name="charCount"
tid="$:/temp/text-to-count-down"/>'>
<$macrocall $name=rpn a=<<charLimit>> b=<<count>> operation=-/>
</$wikify>
</$reveal>

<style>
.te-vt-note-field {
width: 100%;
}
</style>


Have a nice sunday everyone!
Thomas

I think I’ll get a pony of Grappa now.
Post by @TiddlyTweeter
Ciao Thomas
Did you know there are 33.814022558919 PONY to the liter?
https://www.convertunits.com/from/pony/to/liter
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/dcfb1652-afea-4548-ad3f-c6e6d06f6add%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2017-08-16 16:21:32 UTC
Permalink
I'm not sure if this actually works, but it seems to give the right answer:

\define sqr(x) <$macrocall $name="rpn" a=$x$ b=$x$ operation="*"/>
\define pony(hg,len)
<$wikify name=hg2 text="<<rpn $hg$ $hg$ *>>">
<$wikify name=hg2len text='<$macrocall $name="rpn" a=<<hg2>> b=$len$
operation="*"/>'>

<$wikify name=weight text='<$macrocall $name="rpn" a=<<hg2len>> b="11800"
operation="/" decimals=2/>'>

<$macrocall $name="rpn" a=<<weight>> b=" kgs" operation="&" />
</$wikify></$wikify></$wikify>
\end

<<pony 100 200>>

Only the wikify widget made this straight-forward.

I guessed at the pony measurements. Suspect the girth is too small. I
notice that horse calculations tack on 50lbs.

Mark
Post by @TiddlyTweeter
Ciao Thomas
Originally I wasn't really interested in RPN because I'm still looking for
something simple that can add up a column in a table without having to have
a Tiddler per row.
However RPN its growing on me as a way to do simple calculations. *Obvious
applications are, for instance, a measures convertor* (°F -> °C; Euros to
Dollars etc)
Could it, for instance, calculate the weight of your pony? :-)
Just for fun here is the formula for estimating the weight of a pony ...
Pony Weight in Kgs = (heart-girth2 cms x length-from-shoulder-to-tip-of-buttocks
cms) / 11,880
Note: the small "2" on "heart-girth" means "squared". **
Best wishes
Josiah
P.S. ** I'm not making this up. The horse weight calculation thing is
http://www.thehorse.com/articles/27936/estimating-horse-weight-accurately
Post by Thomas Elmiger
I showed my little pony some new tricks.
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/bfe3d495-8178-4e05-9368-17d274e0bf9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 16:47:10 UTC
Permalink
Ciao Mark S. & Thomas

Great stuff. I changed the test values to match slightly better actual
horses I know to check. Its accurate enough for what is a guesstimate in
any case. The formulae differ between sites slightly.

What surprised me was the extent of the code you had to write to do that.
It was for more complex than I ever imagined it would need be. But then I
don't really understand coding.

Best wishes
Josiah
Post by 'Mark S.' via TiddlyWiki
\define sqr(x) <$macrocall $name="rpn" a=$x$ b=$x$ operation="*"/>
\define pony(hg,len)
<$wikify name=hg2 text="<<rpn $hg$ $hg$ *>>">
<$wikify name=hg2len text='<$macrocall $name="rpn" a=<<hg2>> b=$len$
operation="*"/>'>
<$wikify name=weight text='<$macrocall $name="rpn" a=<<hg2len>> b="11800"
operation="/" decimals=2/>'>
<$macrocall $name="rpn" a=<<weight>> b=" kgs" operation="&" />
</$wikify></$wikify></$wikify>
\end
<<pony 100 200>>
Only the wikify widget made this straight-forward.
I guessed at the pony measurements. Suspect the girth is too small. I
notice that horse calculations tack on 50lbs.
Mark
Post by @TiddlyTweeter
Ciao Thomas
Originally I wasn't really interested in RPN because I'm still looking
for something simple that can add up a column in a table without having to
have a Tiddler per row.
However RPN its growing on me as a way to do simple calculations. *Obvious
applications are, for instance, a measures convertor* (°F -> °C; Euros
to Dollars etc)
Could it, for instance, calculate the weight of your pony? :-)
Just for fun here is the formula for estimating the weight of a pony ...
Pony Weight in Kgs = (heart-girth2 cms x length-from-shoulder-to-tip-of-buttocks
cms) / 11,880
Note: the small "2" on "heart-girth" means "squared". **
Best wishes
Josiah
P.S. ** I'm not making this up. The horse weight calculation thing is
http://www.thehorse.com/articles/27936/estimating-horse-weight-accurately
Post by Thomas Elmiger
I showed my little pony some new tricks.
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/14eaba42-f996-4a20-86c1-c4aa53a4ead0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 17:05:01 UTC
Permalink
Ciao Mark S.

Small side footnote ...

I notice that horse calculations tack on 50lbs.


Its true that in guesstimating horse weight from tape measures in actual
stables there is a kind of rule-of-thumb to "add on a few pounds" the
larger and older the horse is. The downside is that if you make that
rule-of-thumb into a codification in computer calculations its starts
drifting off from guesstimate to stab-in-the-dark. I don't think that
formula would well for tiny Shetland Ponies, for instance. But mostly its
in the ballpark.

Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/a0043868-65ad-4a3e-af70-0c16799156b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2017-08-16 17:31:14 UTC
Permalink
The existing formula assumes that the horse is a cylinder of flesh. To make
it more accurate, you would want to do the estimates for the head and legs
separately. I'm pretty sure you could make a separate calculation based on
girth for the additive head and legs (the head and legs would have a higher
percentage bone mass) and get within 10%.

The only use for these measurements that comes to mind is possibly loading
a horse trailer and you need to make sure you're within limits but don't
need to be overly precise.

Ok, now what about the load capacity of an African swallow ...

Mark
Post by @TiddlyTweeter
Ciao Mark S.
Small side footnote ...
I notice that horse calculations tack on 50lbs.
Its true that in guesstimating horse weight from tape measures in actual
stables there is a kind of rule-of-thumb to "add on a few pounds" the
larger and older the horse is. The downside is that if you make that
rule-of-thumb into a codification in computer calculations its starts
drifting off from guesstimate to stab-in-the-dark. I don't think that
formula would well for tiny Shetland Ponies, for instance. But mostly its
in the ballpark.
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/080e8b5c-5da9-4a5a-99ad-9a0d8547cd0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 17:47:12 UTC
Permalink
Post by 'Mark S.' via TiddlyWiki
The only use for these measurements that comes to mind is possibly loading
a horse trailer
There is that. But calculating the rough main body weight bulk is important
in racing. TALL horses that are also lean race faster. Its a but more
complicated than just weight as "hands" (height) come into it. Hands are a
proxy measure of stride. Its the stride to bulk/weight ratio that is likely
the Holy Grail in all this.

On to the African Swallow ...

Josiah
Post by 'Mark S.' via TiddlyWiki
The existing formula assumes that the horse is a cylinder of flesh. To
make it more accurate, you would want to do the estimates for the head and
legs separately. I'm pretty sure you could make a separate calculation
based on girth for the additive head and legs (the head and legs would have
a higher percentage bone mass) and get within 10%.
The only use for these measurements that comes to mind is possibly loading
a horse trailer and you need to make sure you're within limits but don't
need to be overly precise.
Ok, now what about the load capacity of an African swallow ...
Mark
Post by @TiddlyTweeter
Ciao Mark S.
Small side footnote ...
I notice that horse calculations tack on 50lbs.
Its true that in guesstimating horse weight from tape measures in actual
stables there is a kind of rule-of-thumb to "add on a few pounds" the
larger and older the horse is. The downside is that if you make that
rule-of-thumb into a codification in computer calculations its starts
drifting off from guesstimate to stab-in-the-dark. I don't think that
formula would well for tiny Shetland Ponies, for instance. But mostly its
in the ballpark.
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/66fea393-d89b-4d4c-8ef0-9ca238d520ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@TiddlyTweeter
2017-08-16 16:00:06 UTC
Permalink
Ciao Thomas

A small footnote & I'll shut up ... This example I understand but its not
illuminating ...

Most readers would think, well "why not just write the sentence?" ... I
think you need a more complex concatenation.

Best wishes
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/658d5f6a-4433-428a-ae42-8e32de3a8be3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2017-08-16 16:22:26 UTC
Permalink
I think it's demonstrating that "Pi" is handled differently in
concatenation mode.
Post by @TiddlyTweeter
Ciao Thomas
A small footnote & I'll shut up ... This example I understand but its not
illuminating ...
Most readers would think, well "why not just write the sentence?" ... I
think you need a more complex concatenation.
Best wishes
Josiah
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3b5a6c75-6192-48e2-b910-a5fc0ed6d6c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2017-08-16 19:09:38 UTC
Permalink
Anachronistic weight conversion

\define pounds2kgs(lbs) <<rpn $lbs$ 2.20462 / 2>>
\define stones2pounds()
<$wikify name="stonelbs" text='<$macrocall $name="rpn" a=$(stones)$ b=14
operation="*"/>'>

<$wikify name="totlbs" text='<$macrocall $name="rpn" a=<<stonelbs>>
b=$(pounds)$ operation="+" />'>

$(name)$ weighs <$macrocall $name=pounds2kgs lbs=<<totlbs>>/> kgs

</$wikify>
</$wikify>

\end
!! Anachronistic Weight Calculator
Name of person: <$edit-text tiddler="temp/stone/person" tag="input" size=50
default="Enter Name"/><br/>
Weight, stones: <$edit-text tiddler="temp/stone/stones" tag="input" size=10
placeholder="Weight in stones" default="0"/><br/>
Weight, pounds: <$edit-text tiddler="temp/stone/pounds" tag="input" size=10
placeholder="Weight in pounds" default="0"/>

<$vars name={{temp/stone/person}} stones={{temp/stone/stones}}
pounds={{temp/stone/pounds}}>

<<stones2pounds>>

</$vars>
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7e2d44f3-be9f-48bd-8808-261bce6477f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thomas Elmiger
2017-08-16 21:21:13 UTC
Permalink
Pretty cool, Mark!

The other direction:

\define stones() <$macrocall $name=rpn a={{$:/temp/british-weight-converter
}} b=<<rpn 2.20462 14 / >> operation=*/>

The metric weight of
<$edit-text tiddler="$:/temp/british-weight-converter" field="text" tag=
"input" size="3"/> ''kg'' is equal to:

<$wikify name=toPounds text="<$macrocall $name=rpn a=<<stones>> b=1
operation=%/>">
<$macrocall $name=rpn a=<<stones>> b=0 precision=f/> stones <$macrocall
$name=rpn a=<<toPounds>> b=14 operation=* decimals=1/> pounds
</$wikify>


 the shortest solution that came to my mind.

Now I need a rest (i fear dreaming about African Swallows swallowing
ponies).

Good night!
Thomas
Post by 'Mark S.' via TiddlyWiki
Anachronistic weight conversion
\define pounds2kgs(lbs) <<rpn $lbs$ 2.20462 / 2>>
\define stones2pounds()
<$wikify name="stonelbs" text='<$macrocall $name="rpn" a=$(stones)$ b=14
operation="*"/>'>
<$wikify name="totlbs" text='<$macrocall $name="rpn" a=<<stonelbs>>
b=$(pounds)$ operation="+" />'>
$(name)$ weighs <$macrocall $name=pounds2kgs lbs=<<totlbs>>/> kgs
</$wikify>
</$wikify>
\end
!! Anachronistic Weight Calculator
Name of person: <$edit-text tiddler="temp/stone/person" tag="input"
size=50 default="Enter Name"/><br/>
Weight, stones: <$edit-text tiddler="temp/stone/stones" tag="input"
size=10 placeholder="Weight in stones" default="0"/><br/>
Weight, pounds: <$edit-text tiddler="temp/stone/pounds" tag="input"
size=10 placeholder="Weight in pounds" default="0"/>
<$vars name={{temp/stone/person}} stones={{temp/stone/stones}}
pounds={{temp/stone/pounds}}>
<<stones2pounds>>
</$vars>
--
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/195560a8-766b-49d8-ac05-dea2361f2f84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...