Re: valueDiff for arrays

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: valueDiff for arrays

Knapp Martin via use-livecode
Suggestion for the language-token for this function: "transplant".

transplant [qualification] from [SourceArray] to [TargetArray]

[qualification] is a pattern/expression which describes exactly which bits you want to move from SourceArray to TargetArray.

If TargetArray doesn't exist, it should be created to hold the stuff from SourceArray.

It occurs to me that "transplant" might also be useful as a string-manipulation function:

transplant [ChunkType]s where [qualification] from [SourceContainer] to [TargetContainer]

Am thinking that the default behavior should be to have the transplanted bits be added to the *end* of TargetContainer. Again, if TargetContainer doesn't exist, it should be created. It might be useful to be able to specify exactly where the transplanted bits get inserted, so maybe:

transplant [ChunkType]s where [qualification] from [SourceContainer] to [Location] of [TargetContainer]

"Location" could be "start", or "end", at minimum, or possibly an expression that evaluates to a location within TargetContainer.

Am unsure how much of a hassle it would be to implement this, so I shall leave it in the capable hands of Mr. Waddingham & Co.



"Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"
Read the webcomic at [ http://www.atarmslength.net ]!
If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: valueDiff for arrays

Knapp Martin via use-livecode
So the difference between transplant and filter is that transplant mutates both source and target by taking from source and adding to target while filter copies from source to target? Oh and that transplant would mutate an existing target rather than clobbering any existing value.

Hate the name but interesting idea. Personally I’ve been thinking about something like map reduce:

map <chunktype> of <source> [as <valueExpression>] [grouping by <groupExpression>] [where <filterExpression>] into <target>

So if you had a list:

foo,1,2,3
bar,4,5,6
baz,7,8,9

map lines of tList as sum(item 2 to -1 of each)  \
        grouping by item 1 of each \
        where item 1 of each begins with “b” into tArray

Would create the array:

“bar” -> 10, “baz” -> 24

> On 8 Aug 2018, at 8:35 am, Quentin Long via use-livecode <[hidden email]> wrote:
>
> Suggestion for the language-token for this function: "transplant".
>
> transplant [qualification] from [SourceArray] to [TargetArray]
>
> [qualification] is a pattern/expression which describes exactly which bits you want to move from SourceArray to TargetArray.
>
> If TargetArray doesn't exist, it should be created to hold the stuff from SourceArray.
>
> It occurs to me that "transplant" might also be useful as a string-manipulation function:
>
> transplant [ChunkType]s where [qualification] from [SourceContainer] to [TargetContainer]
>
> Am thinking that the default behavior should be to have the transplanted bits be added to the *end* of TargetContainer. Again, if TargetContainer doesn't exist, it should be created. It might be useful to be able to specify exactly where the transplanted bits get inserted, so maybe:
>
> transplant [ChunkType]s where [qualification] from [SourceContainer] to [Location] of [TargetContainer]
>
> "Location" could be "start", or "end", at minimum, or possibly an expression that evaluates to a location within TargetContainer.
>
> Am unsure how much of a hassle it would be to implement this, so I shall leave it in the capable hands of Mr. Waddingham & Co.
>
>
>
> "Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"
> Read the webcomic at [ http://www.atarmslength.net ]!
> If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: valueDiff for arrays

Knapp Martin via use-livecode


> On 8 Aug 2018, at 7:52 pm, Monte Goulding via use-livecode <[hidden email]> wrote:
>
> map lines of tList as sum(item 2 to -1 of each)  \
>        grouping by item 1 of each \
>        where item 1 of each begins with “b” into tArray
>
> Would create the array:
>
> “bar” -> 10, “baz” -> 24

Typo ^ sorry that’s meant to be “bar” -> 15
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: valueDiff for arrays

Knapp Martin via use-livecode
In reply to this post by Knapp Martin via use-livecode
I'd suggest transplant is actually move - an idea which has been taken to the level of obsession in modern c++ and new languages like Rust (which I want to like - but it's highly technical demands just leave a bitter taste in my mouth - impressive, yes; the right approach - definitely not, IMHO anyway!).

For LCS 'move' would allow to elide a put and delete. However there are few cases I can think of (if any!) where it is required save for the fact it would make certain things potentially more performant in the absence of even a relatively simple data-flow based optimisation phase.

Also I'm not sure it could be implemented in the current LCS mechanism to actually give that performance so it would essentially be a bit of syntactic sugar for 'put' then 'delete'.

Perhaps reasonable from the point of view of clear expression of intent though!

Warmest Regards,

Mark.

Sent from my iPhone

> On 7 Aug 2018, at 17:35, Quentin Long via use-livecode <[hidden email]> wrote:
>
> Suggestion for the language-token for this function: "transplant".
>
> transplant [qualification] from [SourceArray] to [TargetArray]
>
> [qualification] is a pattern/expression which describes exactly which bits you want to move from SourceArray to TargetArray.
>
> If TargetArray doesn't exist, it should be created to hold the stuff from SourceArray.
>
> It occurs to me that "transplant" might also be useful as a string-manipulation function:
>
> transplant [ChunkType]s where [qualification] from [SourceContainer] to [TargetContainer]
>
> Am thinking that the default behavior should be to have the transplanted bits be added to the *end* of TargetContainer. Again, if TargetContainer doesn't exist, it should be created. It might be useful to be able to specify exactly where the transplanted bits get inserted, so maybe:
>
> transplant [ChunkType]s where [qualification] from [SourceContainer] to [Location] of [TargetContainer]
>
> "Location" could be "start", or "end", at minimum, or possibly an expression that evaluates to a location within TargetContainer.
>
> Am unsure how much of a hassle it would be to implement this, so I shall leave it in the capable hands of Mr. Waddingham & Co.
>
>
>
> "Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"
> Read the webcomic at [ http://www.atarmslength.net ]!
> If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode