What should this function be named? - (answer group)

Back in the day

I wanted to convert

into

I now need to do the reverse and came up with this custom reporter

But I'm struggling to name it so looking for suggestions

"compact" or "group" by key ?

I like "group" :slight_smile:


Either combine values by keys of $list::lists reporter or merge sub-arrays of $list::lists reporter?

I like having "values" in the label :slight_smile:

V3

V4
I've been adding in some case sensitivity

So starting with this source

Simple group combines all the b (or B) into one row

But case sensitive option seperates the b from the B

cant you just set [case sensitivity V] to <t> ?

Back in the day, I'd believed that not all blocks obeyed the case-sensitivity setting so I've always avoided using it and rolled by own case sensitve code

But testing out
untitled script pic (59)
I can see that this block does so I'll have a go at re-writing it and see what happens :slight_smile:

The basic function lends itself very well to a recursive definition:

Case sensitivity: see @sathvikrias’s post.
Summation (or any other function to be applied on the tail of a list):

Demo

The other reason for avoiding using the set case sensitivity flag is that it applies to all blocks in a program and therefore could have unexpected side affects in other scripts.

Lovely looking code - I really wish I had the ability to think in recursion easily :slight_smile:

For completeness - this was my first simple method of doing it

But I decided to try and re-make it using HOF

So I've redone the HOF version to just use the
groupAndSum script pic (9)
which reduces the number of helper blocks needed considerably (and simplifies everything)

groupAndSum script pic (9)

groupAndSum script pic (13)

So I've come up with this to allow use to choose what function to apply to the grouped values

If you leave it blank it just groups

And you can add it things like sum

And it can handle compound operations as well

This has a workaround for the issues in this thread for discussion on issues of applying functions on tails of lists

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.