*Formula 0.2.0 released*:  https://evanbalster.com/tiddlywiki/formulas.html
GitHub and issue tracking:  https://github.com/EvanBalster/TiddlyWikiFormula

This one's a doozie...  Changelog:

A substantial re-write of the formulas plugin that introduces various 
improvements and improves support for functional programming. Various minor 
compatibility-breaking changes were made.

   - Introduced (lambda) functions and formula-local variables.
      - Added let construct <http://localhost:8080/#LetConstruct> for 
      making local variables.
      - Added function declaration <http://localhost:8080/#Function>. 
      Closures are not supported yet.
   - Added map function <http://localhost:8080/#Functions> for manipulating 
   array elements.
   - Improved number formatting.
      - Default number formatting no longer displays tiny imprecisions.
      - Number formats may be specified with numeral.js 
      <http://numeraljs.com/>, enabling thousands separators, k/m/b 
      notation and greater control over digits.
      - *Renamed some FormulaWidget 
      <http://localhost:8080/#FormulaWidget> and FormulaVarsWidget 
      <http://localhost:8080/#FormulaVarsWidget> attributes.*
      - Original number formatting can still be used by specifying precision 
(no 
      value).
   - Enhanced support for imported values.
      - Added Functions <http://localhost:8080/#Functions> for importing 
      values as text: transclude, transclude_index, variable
      - Added datum function for interpreting text as a Datum 
      <http://localhost:8080/#Datum>.
      - *Datum parsing now recognizes qualifying 14- and 17-digit numbers 
      as TiddlyWiki dates.* (eg. created & modified fields).
   - *Widgets now display errors in the TiddlyWiki style*, like this.
      - $formula-vars will display any errors instead of its normal content.
      - $formula uses tc-error styling.
   - *Value conversion behaviors have changed.*
      - Non-array values will not be treated as single-element arrays.
   - Enhanced array functions sum, average, product and count.
      - Multi-dimensional array values are properly supported.
      - *count ignores empty values.*
      - New function counta counts empty values.
   - Internal implementation was changed. *This will break customizations.*
      - Consolidated "Node" type replaces Operator, Operand and Value.
      - Removed Value "boxing" and percentage values.
      - Implemented a new type cast mechanism, making custom JavaScript 
      functions simpler to write.
      - Computation now uses a "context" object.
   - Fixed doc error: $noRebuild option is not called $noRefresh
   - The substitute and trim functions now process all occurrences, not 
   just one.
   - Fixed implementation of the modulo function.
   - *The % operator no longer affects display style.*
      - Use a format string instread.
   - *+, -, add and subtract no longer auto-sum their operands.*
      - Use sum instead.
   

General remarks:  This makes formula a lot more powerful, especially for 
iterating through arrays with the MAP function.  I might investigate even 
more flexible ways to use that later.  The absence of proper closures does 
make functions and locals less useful as they could be, as local variables 
can't currently be used inside the function supplied to MAP.

For a simple example of a computation that wasn't possible before, see the 
Line Graph demo:  http://localhost:8080/#Demo%3A%20Line%20Graph


On Saturday, 13 January 2018 15:25:29 UTC-6, coda coder wrote:
>
> Ah, the joys of IEEE-754...
>
> <$if "anyone wants to see the gory details of fp in javascript (and a slew 
> of other languages all of which are dependent on today's CPUs)">
>   https://www.h-schmidt.net/FloatConverter/
> </$if>
>
> :)
>
> On Saturday, January 13, 2018 at 2:09:28 PM UTC-6, Evan Balster wrote:
>>
>> Hey, all —
>>
>> I get 5.6000000000000005 as a result (instead of 5.6).
>>>
>>
>> Right now formula uses the JavaScript style for displaying numbers by 
>> default, and it's pretty terrible.  The inaccuracy is "floating point" 
>> error and any reasonable system would round it off somehow.  To get rid of 
>> it, refer to the "fixed" and "precision" options in FormulaWidget:  
>> http://evanbalster.com/tiddlywiki/formulas.html#FormulaWidget
>>
>> I'm probably going to change how numbers are formatted, likely using 
>> numeral.js <http://numeraljs.com/> or something like it.  This is one of 
>> a few compatibility-breaking changes I'm thinking about for the big update.
>>
>>
>> On Saturday, 13 January 2018 13:28:30 UTC-6, ste...@gmail.com wrote:
>>>
>>> Hi Evan, 
>>>
>>> I just ran into a weird problem. When I enter
>>>
>>> (= sum(1.5,1.2,2,0.9) =)
>>>
>>> (= 2+1.2+0.9+1.5 =)
>>>
>>> I get 5.6000000000000005 as a result (instead of 5.6). If I change the 
>>> numbers slightly, I get the correct result. 
>>>
>>> Is this a bug, or is there a well known explanation I'm not aware of?
>>>
>>> Kind regards,
>>>
>>> Stef
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@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/6f27f053-9da0-44a6-9f73-0f1027761aed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to