On Thursday 04 December 2008 18:38:29 William Tanksley, Jr wrote:
> A less trivial use of inverse here would be to write a
> "add-bidirectional-invertable-connection" word so that only one
> connection needs to be defined between both sliders, and 'inverse' is
> automatically used to derive the correspondence between the two
> sliders.
That's a great idea William.
Here's a version of last example which uses just that technique:
http://paste.factorcode.org/paste?id=240
It's pretty short and what's going on is clear, but I'll point out where all
the magic happens.
Make the range models for fahrenhit and celsius:
[let | FAHRENHEIT [ 32 1 32 212 <range> ]
CELSIUS [ 0 1 0 100 <range> ] |
By the way, the effect of range is ( value step min max -- model ).
Then I "tie" them together with:
FAHRENHEIT CELSIUS [ f->c ] range-model-tie
That's it. No 'c->f' to be found. :-) 'range-model-tie' takes care of the
inversion.
The example is so short because it uses "all the right factors" which are
available here (these are also surprisingly concise) :
range-model-label: http://paste.factorcode.org/paste?id=238
range-model-tie: http://paste.factorcode.org/paste?id=239
Ed
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk