Further improvments
Note Split[ ] contains a space
\define all-values(data-tiddler) <$list filter="[[$data-tiddler$]indexes[]]"
variable=item> <$view tiddler=Data index=<<item>>/></$list>
all-values: "<<all-values Data>>"<br>
<$wikify name=string text="<<all-values Data>>">
String: "<<string>>"<br>
<$set name=result filter="[<string>split[ ]sum[]]">
Set sum Result: <<result>><br>
</$set>
<$set name=result filter="[<string>split[ ]count[]]">
Set Count: <<result>><br>
</$set>
<hr>
<$list filter="[<string>split[ ]sum[]]" variable=datum>
List Result: <<datum>><br>
</$list>
<hr>
<$list filter="[<string>split[ ]]" variable=datum>
List Item: <<datum>><br>
</$list>
<hr>
<h3>Count exact number of items with value "1" in prefix/suffix</h3>
<$set name=result filter="[<string>split[ ]prefix[1]suffix[1]count[]]">
Set Count: <<result>><br>
</$set>
<$set name=result filter="[<string>split[ ]prefix[1]suffix[1]sum[]]">
Set Sum: <<result>><br>
</$set>
<$list filter="[<string>split[ ]prefix[1]suffix[1]count[]]" variable=result>
List Result Count: <<result>><br>
</$list>
<$list filter="[<string>split[ ]prefix[1]suffix[1]sum[]]" variable=result>
List Result Sum: <<result>><br>
</$list>
<h3>Best Method? (with Wikify)</h3>
Use this {{{ [<string>split[ ]prefix[1]suffix[1]count[]] }}}
Or this <$text text={{{ [<string>split[ ]prefix[1]suffix[1]count[]] }}}/>
If values only 0 or 1 use `{{{ [<string>split[ ]sum[]] }}}` giving {{{
[<string>split[ ]sum[]] }}}
</$wikify>
I believe further improvement is possible.
Regards
Tony
On Tuesday, June 4, 2019 at 1:30:14 PM UTC+10, TonyM wrote:
>
> Watt,
>
> I have it working in an inelegant way. It only works if the values are 0
> and 1 because summing all ones is also a count of all one's
>
> I will post here without explanation other than unless I use wikify the
> split[ ]sum[] will not work
> \define all-values()
> <$list filter="[[Data]indexes[]]" variable=item>
> <$view tiddler=Data index=<<item>>/>
> </$list>
> \end
>
> all-values: <<all-values>>
>
> <$wikify name=string text="<<all-values>>">
>
> String: <<string>>
>
> <$set name=result filter="[<string>split[]sum[]]">
> Set sum Result: <<result>><br>
> </$set>
>
> <$set name=result filter="[<string>split[]] +[count[]]">
> Set Count: <<result>><br>
> </$set>
>
> <hr>
>
> <$list filter="[<string>split[]sum[]]" variable=datum>
> List Result: <<datum>><br>
> </$list>
>
> <$list filter="[<string>split[]]" variable=datum>
> List: <<datum>><br>
> </$list>
>
> </$wikify>
> The result of Set Count: and List: demonstrates it is still not perfect.
>
>
> I am not so practiced with Data Tiddlers.
>
> Regards
> Tony
>
>
> On Monday, June 3, 2019 at 11:00:22 PM UTC+10, Watt wrote:
>>
>> Thanks TonyM, yes it's a data tiddler with index:value pairs.
>>
>> 01:1
>> 02:0
>> 03:1
>> 04:1
>> 05:0
>> etc.
>>
>> Any clues on counting the '1' values much appreciated.
>>
>>
--
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 post to this group, send email to [email protected].
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/914facdf-e3cb-4b47-b20f-8e5fc3c36617%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.