Re: Help with an algorithm...

2019-08-05 Thread Mark Wieder via use-livecode

On 8/5/19 3:20 PM, dsc--- via use-livecode wrote:

Children are sub-arrays of parents.

Ain't that the truth.

--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread dsc--- via use-livecode
I fixed this to use lists... Maybe.

put parentArray( LISTNEW ) into aNew
put parentArray( LISTOLD )  into aOld
intersect aNew with aOld  -- Remove from aOld that which is not in aNew
union aOld with aNew recursively -- Leaves aNew unchanged except that children 
in aOld are brought in. I think.
put parentList(  aNew ) into LISTNEW

Parents and children are keys in the arrays built. Children are sub-arrays of 
parents.

> On Aug 5, 2019, at 12:31 PM, Dar Scott Consulting via use-livecode 
>  wrote:
> 
> I'm pretty sure I goofed somewhere, but maybe something like this?
> 
> intersect ARRAYNEW with ARRAYOLD into temp
> union temp with ARRAYNEW recursively
> 
> 
>> On Aug 5, 2019, at 9:53 AM, Paul Dupuis via use-livecode 
>>  wrote:
>> 
>> Today is not my coding day. I have a problem I should be able to design a 
>> solution for an am struggling. Clearly I am missing "something"
>> 
>> I have 2 lists (LISTNEW and LISTOLD) of the following format:
>> 
>> ParentA
>> Child 1
>> Child 2
>> etc.
>> ParentB
>> Child 1
>> etc.
>> etc.
>> 
>> The parents are in alphabetical sorted order, the children may not be in 
>> sorted order
>> 
>> I need to hunt through LISTOLD comparing the LISTOLD Parents to the LISTNEW 
>> Parents
>>  FOR any LISTOLD Parent present in LISTNEW, check the Children of the 
>> matching Parents and add any Child for the LISTOLD Parent that is not 
>> already under its matching LISTNEW Parent
>>  FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and its 
>> Children
>> 
>> I can not seem to write an approach to solve this today. Does any body have 
>> some code so solve this they may be willing to share?
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Dar Scott Consulting via use-livecode
I know this does not attend to the question, but my feelings are like this: if 
one has control, go back and use arrays from the start.

Now, to your comments on robustness in parsing the files. I suppose any 
whitespace at the start of a line could be considered a child.  Also, it is an 
error if the first line is a child.

> On Aug 5, 2019, at 3:59 PM, dunbarxx via use-livecode 
>  wrote:
> 
> Hmmm. I had mentioned earlier:
> 
> "You cannot just find matching lines between the two lists, because some
> children 
> AND some parents may be present in both...
> 
> The discussion has focused on array lore, and that is fine, but are we all
> in agreement that the main task is to isolate the parents, regardless of
> whether the names of those parents might be duplicated?  I mention this
> because everything depends on the reliability of those spaces. The parsing
> of parent "groups", in one way or another, is essential.
> 
> Craig
> 
> 
> 
> --
> Sent from: 
> http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread dunbarxx via use-livecode
Hmmm. I had mentioned earlier:

"You cannot just find matching lines between the two lists, because some
children 
AND some parents may be present in both...

 The discussion has focused on array lore, and that is fine, but are we all
in agreement that the main task is to isolate the parents, regardless of
whether the names of those parents might be duplicated?  I mention this
because everything depends on the reliability of those spaces. The parsing
of parent "groups", in one way or another, is essential.

Craig



--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Dar Scott Consulting via use-livecode
My mistake. I was thinking arrays.

> On Aug 5, 2019, at 3:34 PM, Mark Wieder via use-livecode 
>  wrote:
> 
> On 8/5/19 2:24 PM, Dar Scott Consulting via use-livecode wrote:
>> Yikes! I wasn't aware of duplicate keys being a problem. How does that 
>> happen?
> 
> Marx
> Groucho
> Chico
> etc.
> Marx
> Karl
> etc.
> 
> -- 
> Mark Wieder
> ahsoftw...@gmail.com
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Mark Wieder via use-livecode

On 8/5/19 2:24 PM, Dar Scott Consulting via use-livecode wrote:

Yikes! I wasn't aware of duplicate keys being a problem. How does that happen?


Marx
Groucho
Chico
etc.
Marx
Karl
etc.

--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Dar Scott Consulting via use-livecode
Yikes! I wasn't aware of duplicate keys being a problem. How does that happen?

> On Aug 5, 2019, at 2:28 PM, Alex Tweedly via use-livecode 
>  wrote:
> 
> I'm a great fan of, and user of, arrays - but we always need to be careful of 
> losing data with duplicated keys.
> 
> You haven't said that the parent names in LISTNEW are guaranteed to be 
> unique. This simple code assumes they are - if they're not, it's easy to add 
> a check ...  (And it also assumes the inputs are properly formatted!!)
> 
> (inputs are in fields "FNew" and "FOld", output in field "FOut")
> 
> on mouseUp
>local tOld, tNew, tOut
>local tA
>local tLastParent
> 
>put the text of fld "FNew" into tNew
>repeat for each line L in tNew  -- convert to array
>   if L begins with space then -- a child
>  put L  after tA[tLastParent]
>   else
>  put L into tLastParent
>   end if
>end repeat
> 
>put the text of fld "FOld" into tOld
>put empty into tLastParent
>repeat for each line L in tOld
>   if L begins with space then -- a child
>  if (tLastParent is not empty) \
> AND (L is not among the lines of tA[tLastParent]) then
> put L  after tA[tLastParent]
>  end if
>   else
>  if L is among the keys of tA then -- a Parent we need to deal with
> put L into tLastParent
>  else
> put empty into tLastParent
>  end if
>   end if
>end repeat
> 
>-- and then collect the expanded outptu
>local tKeys
>put the keys of tA into tKeys
>sort lines of tKeys
>repeat for each line K in tKeys
>   put K  & tA[K] after tOut
>end repeat
>put tOut into fld "fOut"
> end mouseUp
> 
> Alex.
> 
> 
> On 05/08/2019 16:53, Paul Dupuis via use-livecode wrote:
>> Today is not my coding day. I have a problem I should be able to design a 
>> solution for an am struggling. Clearly I am missing "something"
>> 
>> I have 2 lists (LISTNEW and LISTOLD) of the following format:
>> 
>> ParentA
>> Child 1
>> Child 2
>> etc.
>> ParentB
>> Child 1
>> etc.
>> etc.
>> 
>> The parents are in alphabetical sorted order, the children may not be in 
>> sorted order
>> 
>> I need to hunt through LISTOLD comparing the LISTOLD Parents to the LISTNEW 
>> Parents
>>   FOR any LISTOLD Parent present in LISTNEW, check the Children of the 
>> matching Parents and add any Child for the LISTOLD Parent that is not 
>> already under its matching LISTNEW Parent
>>   FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and its 
>> Children
>> 
>> I can not seem to write an approach to solve this today. Does any body have 
>> some code so solve this they may be willing to share?
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Alex Tweedly via use-livecode
I'm a great fan of, and user of, arrays - but we always need to be 
careful of losing data with duplicated keys.


You haven't said that the parent names in LISTNEW are guaranteed to be 
unique. This simple code assumes they are - if they're not, it's easy to 
add a check ...  (And it also assumes the inputs are properly formatted!!)


(inputs are in fields "FNew" and "FOld", output in field "FOut")

on mouseUp
   local tOld, tNew, tOut
   local tA
   local tLastParent

   put the text of fld "FNew" into tNew
   repeat for each line L in tNew  -- convert to array
  if L begins with space then -- a child
 put L  after tA[tLastParent]
  else
 put L into tLastParent
  end if
   end repeat

   put the text of fld "FOld" into tOld
   put empty into tLastParent
   repeat for each line L in tOld
  if L begins with space then -- a child
 if (tLastParent is not empty) \
    AND (L is not among the lines of tA[tLastParent]) then
    put L  after tA[tLastParent]
 end if
  else
 if L is among the keys of tA then -- a Parent we need to deal with
    put L into tLastParent
 else
    put empty into tLastParent
 end if
  end if
   end repeat

   -- and then collect the expanded outptu
   local tKeys
   put the keys of tA into tKeys
   sort lines of tKeys
   repeat for each line K in tKeys
  put K  & tA[K] after tOut
   end repeat
   put tOut into fld "fOut"
end mouseUp

Alex.


On 05/08/2019 16:53, Paul Dupuis via use-livecode wrote:
Today is not my coding day. I have a problem I should be able to 
design a solution for an am struggling. Clearly I am missing "something"


I have 2 lists (LISTNEW and LISTOLD) of the following format:

ParentA
Child 1
Child 2
etc.
ParentB
Child 1
etc.
etc.

The parents are in alphabetical sorted order, the children may not be 
in sorted order


I need to hunt through LISTOLD comparing the LISTOLD Parents to the 
LISTNEW Parents
  FOR any LISTOLD Parent present in LISTNEW, check the Children of the 
matching Parents and add any Child for the LISTOLD Parent that is not 
already under its matching LISTNEW Parent
  FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and 
its Children


I can not seem to write an approach to solve this today. Does any body 
have some code so solve this they may be willing to share?


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Help with an algorithm...

2019-08-05 Thread Dar Scott Consulting via use-livecode
I'm pretty sure I goofed somewhere, but maybe something like this?

intersect ARRAYNEW with ARRAYOLD into temp
union temp with ARRAYNEW recursively


> On Aug 5, 2019, at 9:53 AM, Paul Dupuis via use-livecode 
>  wrote:
> 
> Today is not my coding day. I have a problem I should be able to design a 
> solution for an am struggling. Clearly I am missing "something"
> 
> I have 2 lists (LISTNEW and LISTOLD) of the following format:
> 
> ParentA
> Child 1
> Child 2
> etc.
> ParentB
> Child 1
> etc.
> etc.
> 
> The parents are in alphabetical sorted order, the children may not be in 
> sorted order
> 
> I need to hunt through LISTOLD comparing the LISTOLD Parents to the LISTNEW 
> Parents
>   FOR any LISTOLD Parent present in LISTNEW, check the Children of the 
> matching Parents and add any Child for the LISTOLD Parent that is not already 
> under its matching LISTNEW Parent
>   FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and its 
> Children
> 
> I can not seem to write an approach to solve this today. Does any body have 
> some code so solve this they may be willing to share?
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


use-list formatting (was Re: Help with an algorithm...)

2019-08-05 Thread Dar Scott Consulting via use-livecode
I agree that the lack of formatting makes it hard to communicate. I would favor 
changing the list settings to allow for it. I don't think we have a spam 
problem that would discourage that.

And to help support this, LC copy should include types easily pasted into mail 
clients. 

> On Aug 5, 2019, at 11:49 AM, dunbarxx via use-livecode 
>  wrote:
> 
> I really do not like the use-list. It is difficult to format one's answers.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread dunbarxx via use-livecode
I saw your post preceded my second one.

Besides the fact that this works as well and is faster:

   repeat for each line tLine in tAll
  put tLine into myArray[ tLine]
   end repeat

The array thing is the easy part. The real working of this gadget depends on
being able to isolate the children, and the only way I can see doing that
easily to rely on those spaces. This may be fragile, depending on how
consistent that format sticks.

You cannot find matching lines between the two lists, because some children
AND some parents may be present in both, and you would not know which
"class" of data you were dealing with. I would format such lists in the
future more robustly, perhaps with tabs.

Craig



--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Dar Scott Consulting via use-livecode
I'd tend to look for ways to do this with functions that work on whole 
collections and avoid loops. 

If that is not found, or is hard to work with, I'd change the lists to be 
arrays.

Each array is is keyed by parents. Each parent is an array of children. 
Children can be represented as an arrayed indexed by children. The elements of 
those might be ignored or have data.  

Loop on keys in LISTNEW...

> On Aug 5, 2019, at 9:53 AM, Paul Dupuis via use-livecode 
>  wrote:
> 
> Today is not my coding day. I have a problem I should be able to design a 
> solution for an am struggling. Clearly I am missing "something"
> 
> I have 2 lists (LISTNEW and LISTOLD) of the following format:
> 
> ParentA
> Child 1
> Child 2
> etc.
> ParentB
> Child 1
> etc.
> etc.
> 
> The parents are in alphabetical sorted order, the children may not be in 
> sorted order
> 
> I need to hunt through LISTOLD comparing the LISTOLD Parents to the LISTNEW 
> Parents
>   FOR any LISTOLD Parent present in LISTNEW, check the Children of the 
> matching Parents and add any Child for the LISTOLD Parent that is not already 
> under its matching LISTNEW Parent
>   FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and its 
> Children
> 
> I can not seem to write an approach to solve this today. Does any body have 
> some code so solve this they may be willing to share?
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread dunbarxx via use-livecode
I really do not like the use-list. It is difficult to format one's answers.

Here is a handler that places a few pieces of data into two variables. These
would be the two isolated lists of children derived from the parents as
described earlier. There is one difference between the two lists, the child
"xxx'.

on mouseUp
   put "aaa" & return & "bbb" & return & "ccc" into tNew
   put "aaa" & return & "xxx" & return & "ccc" into tOld
   put tOld & return & tnew into tAll
   
   repeat with y = 1 to the number of lines of tAll
  put line y of tAll into myArray[ line y of tAll]
   end repeat
  breakpoint
end mouseUp

Straightforward array stuff. The final list has four children, "xxx" being
added to the mix, as can be seen in the debugger at the breakpoint.

Craig




--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Help with an algorithm...

2019-08-05 Thread Paul Dupuis via use-livecode
I had not considered using arrays. I have no idea why, as it provides a 
mechanism. Just not thinking well today. Thanks for the tip!



On 8/5/2019 1:40 PM, dunbarx--- via use-livecode wrote:

Hi.
This seems like a good case for arrays (pseudo):
You have to create an array for each parent. The only way i see to find those 
is to go through the list looking for lines that DO NOT start with a space. If 
you work from the bottom up, since children are always at the bottom and they 
always have spaces in front, you can find the lastMost parent.
Set the itemDel to that parent, and isolate the last item. This will be a list 
of children of that parent.
See if there is a corresponding parent in the new list, and isolate that "item" 
list of children.
Run through the children of the old list and see if they live in the new list. 
If they do, add them:The array part is something like:
put oldChildren & return & newChildren into allChildrenrepeat for each line 
tLine in allChildrenput tLine into myArray[tLine]

Delete the last item of the old list and do it again. This way the last item 
can be isolated directly.
Craig

-Original Message-
From: Paul Dupuis via use-livecode 
To: How to use LiveCode 
Cc: Paul Dupuis 
Sent: Mon, Aug 5, 2019 11:53 am
Subject: Help with an algorithm...

Today is not my coding day. I have a problem I should be able to design
a solution for an am struggling. Clearly I am missing "something"

I have 2 lists (LISTNEW and LISTOLD) of the following format:

ParentA
Child 1
Child 2
etc.
ParentB
Child 1
etc.
etc.

The parents are in alphabetical sorted order, the children may not be in
sorted order

I need to hunt through LISTOLD comparing the LISTOLD Parents to the
LISTNEW Parents
    FOR any LISTOLD Parent present in LISTNEW, check the Children of the
matching Parents and add any Child for the LISTOLD Parent that is not
already under its matching LISTNEW Parent
    FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and
its Children

I can not seem to write an approach to solve this today. Does any body
have some code so solve this they may be willing to share?

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Help with an algorithm...

2019-08-05 Thread dunbarx--- via use-livecode
Hi.
This seems like a good case for arrays (pseudo):
You have to create an array for each parent. The only way i see to find those 
is to go through the list looking for lines that DO NOT start with a space. If 
you work from the bottom up, since children are always at the bottom and they 
always have spaces in front, you can find the lastMost parent.
Set the itemDel to that parent, and isolate the last item. This will be a list 
of children of that parent.
See if there is a corresponding parent in the new list, and isolate that "item" 
list of children.
Run through the children of the old list and see if they live in the new list. 
If they do, add them:The array part is something like:
put oldChildren & return & newChildren into allChildrenrepeat for each line 
tLine in allChildrenput tLine into myArray[tLine]

Delete the last item of the old list and do it again. This way the last item 
can be isolated directly.
Craig

-Original Message-
From: Paul Dupuis via use-livecode 
To: How to use LiveCode 
Cc: Paul Dupuis 
Sent: Mon, Aug 5, 2019 11:53 am
Subject: Help with an algorithm...

Today is not my coding day. I have a problem I should be able to design 
a solution for an am struggling. Clearly I am missing "something"

I have 2 lists (LISTNEW and LISTOLD) of the following format:

ParentA
Child 1
Child 2
etc.
ParentB
Child 1
etc.
etc.

The parents are in alphabetical sorted order, the children may not be in 
sorted order

I need to hunt through LISTOLD comparing the LISTOLD Parents to the 
LISTNEW Parents
   FOR any LISTOLD Parent present in LISTNEW, check the Children of the 
matching Parents and add any Child for the LISTOLD Parent that is not 
already under its matching LISTNEW Parent
   FOR any LISTOLD Parent NOT in LISTNEW, I can ignore the Parent and 
its Children

I can not seem to write an approach to solve this today. Does any body 
have some code so solve this they may be willing to share?

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode