Hey, Stephen —

Yeah, SVG paths are their own mini-language.  As BJ says, 
https://www.w3.org/TR/SVG/paths.html#DAttribute ...

The upshot is that the path is defined by a letter followed by numbers 
(coordinates) with a space between each item.  M marks the start of a path 
and other absolute coordinates may follow it.

TEXTJOIN puts a space between each item produced by MAP.  x&' '&...  Means 
each coordinate is presented as the X-part, a space, and then the rest 
(Y-part).  So the final result will be M and then a series of alternating X 
and Y coordinates.

The code here is also less self-explanatory than it should be, due to lack 
of both closures and comments in formulas.  The "line graph" example is 
already a little more clean / readable in the repository thanks to the 
addition of closure support.  I'll look into making it more understandable 
than it is now.


A sidenote...  TEXTJOIN is probably one of the ugliest functions inherited 
from Excel by formulas.  The function of that TRUE is important (deciding 
whether to include empty items) but it's not clear at all.  Early on I 
decided to maintain backward compatibility with popular spreadsheet 
applications — but it's a little inconvenient when that means inheriting 
their design flaws!


General notice:  I'll be starting a new thread when I release version 
0.2.1.  Another user notified me that it's getting hard to browse this 
thread on his device due to its length and a design issue in Groups' mobile 
implementation.


On Tuesday, 16 January 2018 07:40:06 UTC-6, Stephen Wilson wrote:
>
> I've looked and looked at the the linegraph example... I give up...
> <svg viewBox="0 -50 500 100">
>
> Sets the limits for the svg...
>
> <rect x=0 y=-50 width=500 height=100 stroke=black fill=none/>
>
> Draws the box
>
> <path d=(="M " & textjoin(' ', true,
>
> path d...ok the path has a name..it's name id d...does it have to be d?
> "M"  WHAT IS THIS? (I tried other letters...only M works, what makes it 
> special???
>
>   map(function(x):(x&' '&(sin(x/10)*(x*x)/5000) ), [range[0,500,1]]))
> =) stroke=black stroke-width=1 fill=none/>
> </svg>
> This I get, apart from (x&' '&... the rest is just formula and the area 
> it needs to be drawn in.
>
> I am wondering why when I just have sin(x) as a function noting plots, is 
> it a range issue?
>
> And, can I take the slider code from the starburst demo and use it to 
> change the amplitude/ period of a sine graph (given a suitable starting 
> equation).
>
> Insights from the shallow end.
>
> Ste
>
>
>
> On Tuesday, 16 January 2018 06:08:44 UTC, Evan Balster wrote:
>>
>> Good catch, Diego.  This is actually a symptom of a major value coercion 
>> error in formula 0.2, that gives rise to quite a few different goblins.
>>
>> I'll probably put out a version 0.2.1 tomorrow, as I've fixed this bug 
>> and added closure support (!!) in the repo.
>>
>> On Monday, 15 January 2018 10:31:23 UTC-6, Diego Mesa wrote:
>>>
>>> Hey Evan,
>>>
>>> Again - WOW - thanks!
>>>
>>> Just doing some testing and came across the following:
>>>
>>>    - [tag[Expenses]get[value]]
>>>       - 2.03 1.49 14.90
>>>    - map(function(x):(x*x), [tag[Expenses]get[value]])
>>>       - 4.12 2.22 222.01
>>>    - map(function(x):(x*x* & ','*), [tag[Expenses]get[value]])
>>>       - 4.120899999999999, 2.2201, 222.01000000000002,
>>>    
>>> Diego
>>>
>>> On Monday, January 15, 2018 at 10:26:27 AM UTC-6, Evan Balster wrote:
>>>>
>>>> Hey, Tony —
>>>>
>>>> The JavaScript error is a defect in attribute-modules — that's a core 
>>>> mod with a lot more potential to affect wiki stability, which is why I 
>>>> made 
>>>> some warnings about it.
>>>>
>>>> I think if you grab the latest version of the attribute-modules plugin 
>>>> from the formulas wiki, even though the version number is the same (my 
>>>> mistake), it should fix the issue and restore support for that feature.  
>>>> Sorry about the trouble.
>>>>
>>>> On Monday, 15 January 2018 00:32:42 UTC-6, TonyM wrote:
>>>>>
>>>>> Evan,
>>>>>
>>>>> I dragged the new version plugin to two different wikis, one saved and 
>>>>> reloaded OK.
>>>>>
>>>>> The Other will not reload, nor does safemode work, giving the 
>>>>> following error.
>>>>>
>>>>> Internal JavaScript Error
>>>>> Well, this is embarrassing. It is recommended that you restart 
>>>>> TiddlyWiki by refreshing your browser
>>>>> Error executing boot module 
>>>>> $:/core/modules/widgets/attributes/macro.js: "Cannot find module named 
>>>>> '$:/plugins/ebalster/formula/operands.js' required by module 
>>>>> '$:/core/modules/widgets/attributes/macro.js', resolved to 
>>>>> $:/plugins/ebalster/formula/operands.js" undefined
>>>>>
>>>>> From where I can go no where.
>>>>>
>>>>> I am trying to fix the wiki now but just wanted to let you know.
>>>>>
>>>>> I installed a couple of your other plugins previously the attribute 
>>>>> and if.else plugins if they may have something to do with it.
>>>>>
>>>>> I am not so sure how to toggle a plugin enabled to disable when 
>>>>> editing the tiddlywiki file directly, to eliminate your plugin.
>>>>>
>>>>> Regards
>>>>> Tony
>>>>>
>>>>> On Monday, January 15, 2018 at 4:05:05 PM UTC+11, Evan Balster wrote:
>>>>>>
>>>>>> *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/50c93029-c438-4cc7-b893-738b50fcd25a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to