Re: Interesting(?) Tales of Coding Was : Request for tech note

2017-07-11 Thread Alan Chan via 4D_Tech
I wrote a Get Prime routine in 56 lines of 4D code years ago for fun to 
generate prime number in array of whatever number users enter as parameter.

Alan Chan

4D iNug Technical <4d_tech@lists.4d.com> writes:
>https://i.redd.it/fjcv9evg6u8z.png

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Interesting(?) Tales of Coding Was : Request for tech note

2017-07-11 Thread Chip Scheide via 4D_Tech
https://i.redd.it/fjcv9evg6u8z.png

now THAT is hard work.
I wonder if it was complete...
Chip
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Interesting(?) Tales of Coding Was : Request for tech note

2017-07-10 Thread Roger Reed – Illus House via 4D_Tech
I’d check the third state: “pair-shaped” must have its own validity. Isn’t an 
object pair-shaped?

Roger

> On Jul 10, 2017, at 12:12, Chip Scheide <4d_o...@pghrepository.org> wrote:
> 
> love it
> $Which_Was_It:=Choose(Pair=Pear;"Myspelling/typing";"Damned Auto 
> Correct")
> 
> :)
> 
> Chip
> On Mon, 10 Jul 2017 11:51:33 -0400, Roger Reed – Illus House wrote:
>> Delicious… and beautiful work. Including, that the phrase “
>> pear-shaped” itself went pear-shaped and became “pair-shaped”.
> ---
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Interesting(?) Tales of Coding Was : Request for tech note

2017-07-10 Thread Chip Scheide via 4D_Tech
love it
$Which_Was_It:=Choose(Pair=Pear;"Myspelling/typing";"Damned Auto 
Correct")

:)

Chip
On Mon, 10 Jul 2017 11:51:33 -0400, Roger Reed – Illus House wrote:
> Delicious… and beautiful work. Including, that the phrase “
> pear-shaped” itself went pear-shaped and became “pair-shaped”.
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Interesting(?) Tales of Coding Was : Request for tech note

2017-07-10 Thread Roger Reed – Illus House via 4D_Tech
Delicious… and beautiful work. Including, that the phrase “pear-shaped” itself 
went pear-shaped and became “pair-shaped”.

Thanks,
Roger T. Reed

> On Jul 10, 2017, at 11:14, Chip Scheide via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I picked up a database written in FoxPro (for Mac). This code was 
> running on a Motorola G3 box.
> In it the previous programmer needed to do some combinatorial matrix 
> work.
> In Fox Pro, without having ever seen 4D's set functionality, he 
> basically wrote 4D sets, as string/text operations!!!
> 
> Combinatorial work : list 1 x list 2 where every element of list 1 
> needs to pair with every element of list 2.
> 
> Implementation: Each list element was a string/text, where each list 
> element represented a collection of specific records for a table 
> ([Table X]). In each text/string he represented the inclusion, or 
> exclusion of the records in [Table X] by using a "1", or "0", 
> respectively. ex: "100011101110". He used "0" and "1" (as byte long 
> "bits").
> 
> Then when doing the combinatoric work he ORed the texts together (basic 
> set math doing a union), comparing each character in the strings to one 
> another.
> (basic idea in 4D -- code below written the way it is for a reason)
> For($L;1;$List items)
>  setup_String_one_and_String_two
>  $Final:=""
>  for($i;1;length($String1))
>case of
>  :($string1[[$i]] = "1") & ($string2[[$i]]= "1")
>$Final:=$Final+"1"
>  :($string1[[$i]] = "0") & ($string2[[$i]]= "1")
>$Final:=$Final+"1"
>  :($string1[[$i]] = "1") & ($string2[[$i]]= "0")
>$Final:=$Final+"1"
>else
>$Final:=$Final+"0"
>end case
>  end for
>  Create record([table x])
>   [Table x]Final:=$Final
>   [Table X]Identifier := appropriate identification
>  save record([Table X])
> end for
> Check_for_Duplicate_Strings_in_Table_X
> 
> 
> However, as amazing as this was 
> This worked well, until the length of the string (i.e. number of 
> records) exceeded about 200. At which point
> the system took >> 2 days to Run, AND failed, due to data file size 
> exceeding maximum allowed (about 2gb). His method created (at failure) 
> in the vicinity of 5 million records.
> 
> I expect looking at the above code, you can see where everything went 
> pair-shaped as the data got larger... but just in case.
> - he saves every record (including duplicates), hard drive not SSD 
> (such things were not even conceived of)
> - he touches every record of the combinations 2x, once to create it, 
> then again to determine if there are duplicates (BTW - duplicates in 
> this situation were in excess 99.8% of the data)
> - he doesn't "short-cut" the boolean logic of the text comparisions 
> resulting in a lot of extra comparison work inside nested for loops.
> 
> Again all of this on high hundreds-mega hertz, or very low giga hertz 
> G3 processor. 
> 
> By doing 2 things to his code, I got the routine to complete, reduced 
> the execution time from >> 2 days to 8 hours, and ended up with a net 
> of about 100,000 records.
> How?
> - 1st
> IF ($String1[[$i]] = "0") & ($String2[[$i]] = "0")
>$Final:=$Final + "0"
> else
>$FINAL:=$Final + "1"
> end if
> - 2nd
> query([Table X];[Table X]Final = $Final)
> 
> if(records in selection([Table X]) = 0)
> Create record([table X])
> .
> .
> .
> end if
> On Sat, 8 Jul 2017 08:20:19 +1000, David Adams via 4D_Tech wrote:
>> 
>> Dennis Gallagher sent me something totally unexpected. I think that it is a
>> V1 tech note, TN #92 from 1988 titled “Multi-Dimensional Arrays in 4th
>> Dimension” by Djundi Karjadi & Joshua Wachs and later modified by Dave
>> Terry & Ron Dell’Aquila. These guys were *emulating* 2D arrays using 1D
>> arrays. I'm not worthy! I'm going to check it out as it's probably got some
>> good ideas about packing.
> ---
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Interesting(?) Tales of Coding Was : Request for tech note

2017-07-10 Thread Chip Scheide via 4D_Tech
I picked up a database written in FoxPro (for Mac). This code was 
running on a Motorola G3 box.
In it the previous programmer needed to do some combinatorial matrix 
work.
In Fox Pro, without having ever seen 4D's set functionality, he 
basically wrote 4D sets, as string/text operations!!!

Combinatorial work : list 1 x list 2 where every element of list 1 
needs to pair with every element of list 2.

Implementation: Each list element was a string/text, where each list 
element represented a collection of specific records for a table 
([Table X]). In each text/string he represented the inclusion, or 
exclusion of the records in [Table X] by using a "1", or "0", 
respectively. ex: "100011101110". He used "0" and "1" (as byte long 
"bits").

Then when doing the combinatoric work he ORed the texts together (basic 
set math doing a union), comparing each character in the strings to one 
another.
(basic idea in 4D -- code below written the way it is for a reason)
For($L;1;$List items)
  setup_String_one_and_String_two
  $Final:=""
  for($i;1;length($String1))
case of
  :($string1[[$i]] = "1") & ($string2[[$i]]= "1")
$Final:=$Final+"1"
  :($string1[[$i]] = "0") & ($string2[[$i]]= "1")
$Final:=$Final+"1"
  :($string1[[$i]] = "1") & ($string2[[$i]]= "0")
$Final:=$Final+"1"
else
$Final:=$Final+"0"
end case
  end for
  Create record([table x])
   [Table x]Final:=$Final
   [Table X]Identifier := appropriate identification
  save record([Table X])
end for
Check_for_Duplicate_Strings_in_Table_X


However, as amazing as this was 
This worked well, until the length of the string (i.e. number of 
records) exceeded about 200. At which point
the system took >> 2 days to Run, AND failed, due to data file size 
exceeding maximum allowed (about 2gb). His method created (at failure) 
in the vicinity of 5 million records.
  
I expect looking at the above code, you can see where everything went 
pair-shaped as the data got larger... but just in case.
- he saves every record (including duplicates), hard drive not SSD 
(such things were not even conceived of)
- he touches every record of the combinations 2x, once to create it, 
then again to determine if there are duplicates (BTW - duplicates in 
this situation were in excess 99.8% of the data)
- he doesn't "short-cut" the boolean logic of the text comparisions 
resulting in a lot of extra comparison work inside nested for loops.

Again all of this on high hundreds-mega hertz, or very low giga hertz 
G3 processor. 

By doing 2 things to his code, I got the routine to complete, reduced 
the execution time from >> 2 days to 8 hours, and ended up with a net 
of about 100,000 records.
How?
- 1st
 IF ($String1[[$i]] = "0") & ($String2[[$i]] = "0")
$Final:=$Final + "0"
 else
$FINAL:=$Final + "1"
 end if
- 2nd
query([Table X];[Table X]Final = $Final)

if(records in selection([Table X]) = 0)
 Create record([table X])
.
.
.
end if
On Sat, 8 Jul 2017 08:20:19 +1000, David Adams via 4D_Tech wrote:
> 
> Dennis Gallagher sent me something totally unexpected. I think that it is a
> V1 tech note, TN #92 from 1988 titled “Multi-Dimensional Arrays in 4th
> Dimension” by Djundi Karjadi & Joshua Wachs and later modified by Dave
> Terry & Ron Dell’Aquila. These guys were *emulating* 2D arrays using 1D
> arrays. I'm not worthy! I'm going to check it out as it's probably got some
> good ideas about packing.
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**