Re: valueDiff for arrays?

2018-08-06 Thread Brian Milby via use-livecode
button "Array (original)"
Found 664579 primes in 51.543966 seconds
button "Array (bwm)"
Found 664579 primes in 49.139622 seconds
button "Array (mark)"
Found 664579 primes in 43.483821 seconds
button "Byte (alex)"
Found 664579 primes in 15.016109 seconds
button "Byte (bwm)"
Found 664579 primes in 11.357213 seconds
button "Byte (bernd)"
Found 664579 primes in 7.874756 seconds

I've uploaded a stack with each version of the function.  The last has some
comments added as well.  Mark's version is pretty close to the original,
but did not return an ordered list (which is an implicit requirement).  I
added a sort so the times are comparable.

https://milby.us/lc/Primes.livecode

To Mark's point about C... the person that originally devised the test was
using it to baseline and compare several scripting languages relative to
optimized C++ code.  For LCS, we had to do a bit of work to overcome the
way arrays are stored internally (hash map).  Yes, LCS is still much slower
in this test than everything else listed.  I didn't try any on my seat, so
the times are not really directly comparable, but Python/Perl both did one
run in about 2.5s on average.

This kind of makes me want to translate this into LCB to do a comparison.
There we do have a real list type that could be used and compared against
the other methods employed here.

Thanks,
Brian
___
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: valueDiff for arrays?

2018-08-06 Thread Mark Waddingham via use-livecode
I'd expect that for two reasons.

The first is that all array keys are interred strings (names) so integers need 
to first be converted to strings and then hashed into a name and then hashed to 
the slot in the arrays hash table.

The second is that byte based version is essentially using a byte sequence as a 
bit set - each setting of a byte in the set is about as close as you get to a 
truly atomic (in the sense of using '1' instruction) as you can get in LC.

It is what you would do in C if you couldn't be bothered using bit operations 
to manipulate individual bits in machine words (which would be substantially 
faster again - as you would be touching 1/8th of the memory).

Warmest Regards,

Mark.

Sent from my iPhone

> On 6 Aug 2018, at 20:24, Mark Wieder via use-livecode 
>  wrote:
> 
> Interesting. I tried a variation using arrays, and it's three times slower 
> than yours.
> 
> function get_primes pN
>   local tMroot, tPrimes, tIsItPrime
> 
>   if pN < 2 then return empty
>   if pN = 2 then return 2
>   put trunc(sqrt(pN)) - 1 into tMroot
> 
>   repeat with i=1 to pN step 2
>  put 1 into tIsItPrime[i]
>   end repeat
> 
>   repeat with i = 3 to tMroot step 2
>  if tIsItPrime[i] is empty then next repeat
>  repeat with j = i^2 to pN step i
> delete variable tIsItPrime[j]
>  end repeat
>   end repeat
> 
>   return the keys of tIsItPrime
> end get_primes
> 
> -- 
> 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: valueDiff for arrays?

2018-08-06 Thread Mark Wieder via use-livecode
Interesting. I tried a variation using arrays, and it's three times 
slower than yours.


function get_primes pN
   local tMroot, tPrimes, tIsItPrime

   if pN < 2 then return empty
   if pN = 2 then return 2
   put trunc(sqrt(pN)) - 1 into tMroot

   repeat with i=1 to pN step 2
  put 1 into tIsItPrime[i]
   end repeat

   repeat with i = 3 to tMroot step 2
  if tIsItPrime[i] is empty then next repeat
  repeat with j = i^2 to pN step i
 delete variable tIsItPrime[j]
  end repeat
   end repeat

   return the keys of tIsItPrime
end get_primes

--
 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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread Sannyasin Brahmanathaswami via use-livecode
I found another way.

Set standard background a opacity=0

add an new container graphic.

then make the background bigger that the controls, But it won't hilite.

So I might use your method.

On 8/6/18 11:33 AM, zryip theSlug via use-livecode wrote:
> I have created this kind of form before: roundrect background and margins
> between 2 rows.
> For the background I used my own graphic. The background graphic if present
> is used by the datagrid library for hiliting the row. I removed it.
> And for magins, I used a row height upper than the height of my custom
> background. The margins between 2 rows are transparent, so I was able to
> see the card's background without doing something specific with the
> datagrid.



___
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: valueDiff for arrays?

2018-08-06 Thread Niggemann, Bernd via use-livecode
How embarrassing, again an error. I should go to sleep now.

 repeat pn mod 1
  put tYes after tIsItPrime <-- corrected line
   end repeat

Here is the hopfully truly truly last correction.

---
function get_primes pN -- bn modified brian
   local tMroot, tPrimes, tIsItPrime, tYes, tNo
   put numtobyte(66) into tYes
   put numtobyte(65) into tNo
   if pN < 2 then return empty
   if pN = 2 then return 2
   put 2 into tPrimes
   put trunc(sqrt(pN)) - 1 into tMroot
   
   if pN >= 1 then
  local tTenThousand
  repeat 1
 put tYes after tTenThousand
  end repeat
  
  repeat pn div 1
 put tTenthousand after tIsItPrime
  end repeat
   end if
   
   repeat pn mod 1
  put tYes after tIsItPrime
   end repeat
   
   repeat with i = 3 to tMroot step 2
  if byte i of tIsItPrime is tNo then next repeat
  put cr & i after tPrimes
  repeat with j = i^2 to pN step i
 put tNo into byte j of tIsItPrime
  end repeat
   end repeat
   repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2
  if byte i of tIsItPrime is tYes then put cr & i after tPrimes
   end repeat
   return tPrimes
end get_primes
--

at least it saves a couple of seconds

Kind regards
Bernd

___
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: valueDiff for arrays?

2018-08-06 Thread Alex Tweedly via use-livecode

Nice improvement !

And I like the variable names much more ... though it could be argued 
that "tYes", should be called"tMayYetBeAPrime" :-)


I now get this version consistently running in 25% of the original time.

There is another version which runs about twice as fast - i.e. 14% of 
the original - but I'm not sure it is quite within the spirit of this 
comparison.


This should be a comparison of the performance of "the same" algorithm 
in a variety of scripting languages. It seems wrong to speed up our LC 
implementation by tweaking the algorithm.


If our purpose was simply to improve the speed of finding primes, that 
would be different.


So for anyone who wants to find primes faster - here revised code that 
does so, though I doubt if it tells us anything about the relative 
performance of LC.


The "pure" version of the Sieve would have crossed all multiples of 
every prime, but the original code only needs to cross-off those 
multiples of 3 and above - i.e the 'pure' inner loop would be


repeat with i = 2 to tMroot
rather than
repeat with i = 3 to tMroot step 2

The original code is an improvement over the 'pure' version by taking 
advantage of the knowledge that all even numbers (>2) cannot be 
prime.You can do (part of) that optimization for all primes up to 
(small) 'm' rather than just for '2'.  Pre-calculate the pattern for 
1...M (where big M is the product of all primes <= small m), and then 
initialize the sieve table with that pattern repeated as often as 
needed. Then you can go through the sieve crossing-off only for primes > 
'm'. This code uses m=5 (i.e. M=2*3*5=30).




function get_primes pN
   local tMroot, tPrimes, tIsItPrime, tYes, tNo
   put numtobyte(66) into tYes
   put numtobyte(65) into tNo
   if pN < 2 then return empty
   if pN = 2 then return 2
   repeat with i = 1 to 30
  put tNo into byte i of tIsItPrime
   end repeat
   repeat for each item L in "1,7,11,13,17,19,23,29"
  put tYes into byte L of tIsItPrime
   end repeat
   local t30
   put byte 1 to 30 of tIsItPrime into t30
   put t30 into tIsItPrime
   repeat pN div 30 times
  put t30 after tIsItPrime
   end repeat

   put 2  & 3 & CR & 5  into tPrimes
   put trunc(sqrt(pN)) - 1 into tMroot
   repeat with i = 7 to tMroot step 2
  if byte i of tIsItPrime is tNo then next repeat
  put cr & i after tPrimes
  repeat with j = i^2 to pN step i
 put tNo into byte j of tIsItPrime
  end repeat
   end repeat
   repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2
  if byte i of tIsItPrime is tYes then put cr & i after tPrimes
   end repeat
   return tPrimes
end get_primes

and that runs in just over half the time.

Alex.


___
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: valueDiff for arrays?

2018-08-06 Thread Niggemann, Bernd via use-livecode
There was an error in the code I posted.
It should read "if pN >= 1 then" instead of "if pN > 1"

this is the corrected version
-
function get_primes pN
   local tMroot, tPrimes, tIsItPrime, tYes, tNo
   put numtobyte(66) into tYes
   put numtobyte(65) into tNo
   if pN < 2 then return empty
   if pN = 2 then return 2
   put 2 into tPrimes
   put trunc(sqrt(pN)) - 1 into tMroot
   
   if pN >= 1 then
  local tTenThousand
  repeat 1
 put tYes after tTenThousand
  end repeat
  
  repeat pn div 1
 put tTenthousand after tIsItPrime
  end repeat
   end if
   
   repeat pn mod 1
  put tTenthousand after tIsItPrime
   end repeat
   
   repeat with i = 3 to tMroot step 2
  if byte i of tIsItPrime is tNo then next repeat
  put cr & i after tPrimes
  repeat with j = i^2 to pN step i
 put tNo into byte j of tIsItPrime
  end repeat
   end repeat
   repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2
  if byte i of tIsItPrime is tYes then put cr & i after tPrimes
   end repeat
   return tPrimes
end get_primes
---

Kind regards
Bernd

___
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: valueDiff for arrays?

2018-08-06 Thread Brian Milby via use-livecode
2 should be included, but the original optimized version skipped it.

Thanks,
Brian
On Aug 6, 2018, 6:25 PM -0500, Niggemann, Bernd via use-livecode 
, wrote:
> This also helps a bit. Where is Hermann?
>
> -
> function get_primes pN
> local tMroot, tPrimes, tIsItPrime, tYes, tNo
> put numtobyte(66) into tYes
> put numtobyte(65) into tNo
> if pN < 2 then return empty
> if pN = 2 then return 2
> put 2 into tPrimes
> put trunc(sqrt(pN)) - 1 into tMroot
>
> if pN > 1 then
> local tTenThousand
> repeat 1
> put tYes after tTenThousand
> end repeat
>
> repeat pn div 1
> put tTenthousand after tIsItPrime
> end repeat
> end if
>
> repeat pn mod 1
> put tTenthousand after tIsItPrime
> end repeat
>
> repeat with i = 3 to tMroot step 2
> if byte i of tIsItPrime is tNo then next repeat
> put cr & i after tPrimes
> repeat with j = i^2 to pN step i
> put tNo into byte j of tIsItPrime
> end repeat
> end repeat
> repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2
> if byte i of tIsItPrime is tYes then put cr & i after tPrimes
> end repeat
> return tPrimes
> end get_primes
> 
>
> This is a modified Brian´s version built upon Alex's version
>
> Note that Brian seems to find one additional prime.
>
> Kind regards
> Bernd
>
> ___
> 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: valueDiff for arrays?

2018-08-06 Thread Niggemann, Bernd via use-livecode
This also helps a bit. Where is Hermann?

-
function get_primes pN
   local tMroot, tPrimes, tIsItPrime, tYes, tNo
   put numtobyte(66) into tYes
   put numtobyte(65) into tNo
   if pN < 2 then return empty
   if pN = 2 then return 2
   put 2 into tPrimes
   put trunc(sqrt(pN)) - 1 into tMroot
   
   if pN > 1 then
  local tTenThousand
  repeat 1
 put tYes after tTenThousand
  end repeat
  
  repeat pn div 1
 put tTenthousand after tIsItPrime
  end repeat
   end if
   
   repeat pn mod 1
  put tTenthousand after tIsItPrime
   end repeat
   
   repeat with i = 3 to tMroot step 2
  if byte i of tIsItPrime is tNo then next repeat
  put cr & i after tPrimes
  repeat with j = i^2 to pN step i
 put tNo into byte j of tIsItPrime
  end repeat
   end repeat
   repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2
  if byte i of tIsItPrime is tYes then put cr & i after tPrimes
   end repeat
   return tPrimes
end get_primes


This is a modified Brian´s version built upon Alex's version

Note that Brian seems to find one additional prime.

Kind regards
Bernd

___
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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Jerry Jensen via use-livecode


> On Aug 6, 2018, at 3:18 PM, Mark Waddingham via use-livecode 
>  wrote:
> 
> Although I think I digested Toolbook's reference guide / dictionary at some 
> point (by reading, not by actually eating and digesting!).

An artist friend of mine attempted to _eat_ the Guiness Book of World Records. 
It proved to be infeasible. The attempt was recorded on an early Sony porta-pak 
and transferred (with difficulty) to youtube:
https://www.youtube.com/watch?v=Qceil955Rcw
Do not try this at home!
.Jerry


___
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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Mark Waddingham via use-livecode

On 2018-08-06 21:49, Richard Gaskin via use-livecode wrote:

Mark Waddingham wrote:


I think it might be quite unique amongst x-talks in another way too...

How much of any of the others were written in themselves?


Not many.  Toolbook, Gain Momentum, and SuperCard are the only ones I
can think of beyond LC that had enough confidence in their tooling to
use it to make their tooling.


I couldn't remember whether SuperCard's IDE was written in SuperCard or 
not, interesting to know. I must confess I've never really had any 
experience with Toolbook or Gain Momentum... Although I think I digested 
Toolbook's reference guide / dictionary at some point (by reading, not 
by actually eating and digesting!).


In any case, looks like we have a bit more work to do before we can 
truly claim we are unique amongst x-talks on that particular vector...


Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread zryip theSlug via use-livecode
Dear Swami,

I have created this kind of form before: roundrect background and margins
between 2 rows.
For the background I used my own graphic. The background graphic if present
is used by the datagrid library for hiliting the row. I removed it.
And for magins, I used a row height upper than the height of my custom
background. The margins between 2 rows are transparent, so I was able to
see the card's background without doing something specific with the
datagrid.

On Mon, Aug 6, 2018 at 9:03 PM, Sannyasin Brahmanathaswami via use-livecode
 wrote:

> On 8/6/18 7:29 AM, zryip theSlug via use-livecode wrote:
> > Bob,
> >
> > A column template exists for each column of a dg table, so you can use
> any
> > control you want inside a datagrid column, including widgets.
> >
> > Here is a link to a DGH's screenshot . On the left, we have properties
> for
> > a column (row or header). This is a datagrid table with two visible
> > columns. The second column is displaying checkboxes, text, popup menus,
> > images, widgets, etc depending of the property type. This is not a trick,
> > this is perfectly supported by datagrid tables.
> >
> > https://livecode.com/wp-content/uploads/2018/06/image14-26.png
> >
> > On Mon, Aug 6, 2018 at 6:22 PM, Bob Sneidar via use-livecode <
> > use-livecode@lists.runrev.com> wrote:
> >
> >> The template is like the group editor. In fact it may actually BE the
> >> group editor. The behavior script determines what to do when a row is
> >> drawn.
> >>
> >> I think the thing to understand about datagrids, table or forms, is that
> >> for each array element in the data (itself an array) the template is
> >> "cloned". Each row is a "clone" of the template. But for forms, the
> >> behavior does not know what you want to do when the rows are created.
> For
> >> instance, you may want to color negative numbers in red, or surround
> them
> >> with parenthesis. You may have a button that needs to be hilited or not
> >> depending on the value for that control. Perhaps you have a field that
> can
> >> contain multiple lines of text, and you need to set the row height for
> each
> >> row based upon the formattedHeight of that field. Or maybe show and hide
> >> objects etc.
> >>
> >> The beauty of a form datagrid is that how each individual row gets drawn
> >> is entirely under your own programmatical control. A table datagrid is
> >> simply like a spreadsheet with fixed row heights and no support for
> >> graphics or other controls.
> >>
> >> BTW I kinda cheated and made a way to have checkboxes for a table style
> >> datagrid. I simply had a group with checkboxes overlaying a "dummy"
> column
> >> in the datagrid. When I queried for data I put something like:
> >>
> >> SELECT '' AS checkmark, '' AS checkmarkvalue, * FROM customers
> >>
> >> This put two empty strings in my array data (I use sqlYoga so I get
> arrays
> >> back instead of cursors, but the idea is the same). I only defined a
> column
> >> for "checkmark", but NOT for "checkmarkvalue". This allowed me to have a
> >> blank column to overlay the checkboxes on, and a hidden column to hold
> the
> >> checkmarkvalue for each row in the datagrid data.
> >>
> >> Then when I populated the datagrid, I hid all the checkboxes then showed
> >> each checkbox control based upon how much data was being displayed. Of
> >> course, you have to account for scrolling, so that can be tricky, but it
> >> was a poor man's way of adding checkboxes to a table datagrid. Others
> could
> >> probably come up with a more elegant solution.
> >>
> >> Bob S
> >>
> >>
> >>> On Aug 5, 2018, at 10:03 , Sannyasin Brahmanathaswami via use-livecode
> <
> >> use-livecode@lists.runrev.com> wrote:
> >>> I slowly studying as much as we can on the datagrid,and "digging" in it
> >> with an first attempt to build a form.
> >>> One thing is not clear to me.
> >>>
> >>> 1) Have the  WYSIG panel to build the datagrid form.
> >>>
> >>> 2) why then do we  have, in the Behavior Script  this handler?
> >>>
> >>> Isn't the layout already pre-determined in the template?
> >>
> >> ___
> >> 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
>



-- 
Zryip TheSlug
http://www.aslugontheroad.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: valueDiff for arrays?

2018-08-06 Thread Brian Milby via use-livecode
Ah, that is what I was missing (numtobyte)... I knew that 4000 seconds
wasn't right :)
I was able to shave a bit more off by only calling numtobyte twice (17s to
12s for single pass):

function get_primes pN
   local tMroot, tPrimes, tIsItPrime, tYes, tNo
   put numtobyte(66) into tYes
   put numtobyte(65) into tNo
   if pN < 2 then return empty
   if pN = 2 then return 2
   put 2 into tPrimes
   put trunc(sqrt(pN)) - 1 into tMroot
   repeat with i = 1 to pN
  put tYes into byte i of tIsItPrime
   end repeat
   repeat with i = 3 to tMroot step 2
  if byte i of tIsItPrime is tNo then next repeat
  put cr & i after tPrimes
  repeat with j = i^2 to pN step i
 put tNo into byte j of tIsItPrime
  end repeat
   end repeat
   repeat with i = tMroot + (tMroot + 1) mod 2 to pN - 1 step 2
  if byte i of tIsItPrime is tYes then put cr & i after tPrimes
   end repeat
   return tPrimes
end get_primes

I also changed the variable names a bit :)

On Mon, Aug 6, 2018 at 3:25 PM, Mark Waddingham via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On 2018-08-06 22:04, Alex Tweedly via use-livecode wrote:
>
>> On 06/08/2018 16:50, Mark Waddingham via use-livecode wrote:
>>
>> Alex Tweedly didn't talk nonsense... Byte x [to y] of z is (truly)
>>> constant time if z is strictly a binary string.
>>>
>> That's right - the basic principle wasn't nonsense - but most
>> everything else in my email was :-)
>>
>
> Well I spoke a bit of nonsense in the above - only byte x of z is constant
> time (if z is strictly a binary string) - byte x to y of z - is O(n) where
> n = y - x.
>
> Of course the reality is that it should be possibly for it to be constant
> for both - chunk ranges of things should be able to be created in constant
> time as they can reference the thing they are chunking... However, the
> reason we have yet to do that is that ownership of the values need to be
> 'understood' (as in modelled in the engine at runtime) to ensure small
> chunks of much larger strings don't cause the much larger strings to stay
> hanging around when they are no longer referenced.
>
> e.g. You have a 20Mb text file which you chunk and extract only 1Kb worth
> of small strings from. You don't want the 20Mb remaining in memory when its
> not needed anymore. A naive implementation of substrings would cause that
> to happen and cause the size of the heap to blow up in size with nothing
> you (as the programmer) could do about it.
>
> I said you only needed to change two lines - in fact you need to make
>> changes in 4 places.
>> I said the saving was ~ 40%, in fact it's ~75-80%
>>
>
> I don't think anyone is going to complain where 'nonsense' is actually a
> misstatement by a factor of 2 (in the better way!) over a performance
> improvement :)
>
> First wrong thing - you can't just casually write into  "byte X of
>> tmp". if X is greater than the current length of tmp, then this simply
>> appends a single byte. So you need to pre-fill the variable that holds
>> the bytes.
>>
>
> Yes - it's the same for all 'put into ' expressions I believe. I
> can't really say whether the alternative (i.e. padding) would be more
> 'correct' or not (well, not without a good deal of pondering!) - certainly
> useful though, in this particular case.
>
> Regardless of correctness - pre-filling the binary string has a memory
> allocation advantage as well. It can be quite expensive (O(n) in fact -
> where n is the existing length) to extend a string (binary or otherwise)
> beyond its current length. So if you pre-fill the length you want, no
> memory allocation has to happen during use of it.
>
> Second wrong thing was
>>   put "a" into byte X of np
>> that should be
>>   put numtobyte(66) into byte X of np
>>
>> I don't thin this *should* make much difference - but in fact it makes
>> a huge difference. Not sure why - I suspect a bug  I'll look at it
>> some more and hopefully submit a bug report later.
>>
>
> The issue there is that you are mixing text with binary. I think the
> engine assumes (currently) in that case that you mean the target to be
> text... Although I *think* we fixed that case recently in a patch to appear
> in either 9.0.1 or 9.1.0 (maybe Ali can comment on that). If you explicitly
> say 'byte' in the target then it should end up being binary that you get.
>
> Warmest Regards,
>
> Mark.
>
> --
> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
> ___
> 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: valueDiff for arrays?

2018-08-06 Thread Mark Waddingham via use-livecode

On 2018-08-06 22:04, Alex Tweedly via use-livecode wrote:

On 06/08/2018 16:50, Mark Waddingham via use-livecode wrote:

Alex Tweedly didn't talk nonsense... Byte x [to y] of z is (truly) 
constant time if z is strictly a binary string.

That's right - the basic principle wasn't nonsense - but most
everything else in my email was :-)


Well I spoke a bit of nonsense in the above - only byte x of z is 
constant time (if z is strictly a binary string) - byte x to y of z - is 
O(n) where n = y - x.


Of course the reality is that it should be possibly for it to be 
constant for both - chunk ranges of things should be able to be created 
in constant time as they can reference the thing they are chunking... 
However, the reason we have yet to do that is that ownership of the 
values need to be 'understood' (as in modelled in the engine at runtime) 
to ensure small chunks of much larger strings don't cause the much 
larger strings to stay hanging around when they are no longer 
referenced.


e.g. You have a 20Mb text file which you chunk and extract only 1Kb 
worth of small strings from. You don't want the 20Mb remaining in memory 
when its not needed anymore. A naive implementation of substrings would 
cause that to happen and cause the size of the heap to blow up in size 
with nothing you (as the programmer) could do about it.



I said you only needed to change two lines - in fact you need to make
changes in 4 places.
I said the saving was ~ 40%, in fact it's ~75-80%


I don't think anyone is going to complain where 'nonsense' is actually a 
misstatement by a factor of 2 (in the better way!) over a performance 
improvement :)



First wrong thing - you can't just casually write into  "byte X of
tmp". if X is greater than the current length of tmp, then this simply
appends a single byte. So you need to pre-fill the variable that holds
the bytes.


Yes - it's the same for all 'put into ' expressions I believe. I 
can't really say whether the alternative (i.e. padding) would be more 
'correct' or not (well, not without a good deal of pondering!) - 
certainly useful though, in this particular case.


Regardless of correctness - pre-filling the binary string has a memory 
allocation advantage as well. It can be quite expensive (O(n) in fact - 
where n is the existing length) to extend a string (binary or otherwise) 
beyond its current length. So if you pre-fill the length you want, no 
memory allocation has to happen during use of it.



Second wrong thing was
  put "a" into byte X of np
that should be
  put numtobyte(66) into byte X of np

I don't thin this *should* make much difference - but in fact it makes
a huge difference. Not sure why - I suspect a bug  I'll look at it
some more and hopefully submit a bug report later.


The issue there is that you are mixing text with binary. I think the 
engine assumes (currently) in that case that you mean the target to be 
text... Although I *think* we fixed that case recently in a patch to 
appear in either 9.0.1 or 9.1.0 (maybe Ali can comment on that). If you 
explicitly say 'byte' in the target then it should end up being binary 
that you get.


Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
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: valueDiff for arrays?

2018-08-06 Thread Alex Tweedly via use-livecode

On 06/08/2018 16:50, Mark Waddingham via use-livecode wrote:


Alex Tweedly didn't talk nonsense... Byte x [to y] of z is (truly) constant 
time if z is strictly a binary string.
That's right - the basic principle wasn't nonsense - but most everything 
else in my email was :-)


I said you only needed to change two lines - in fact you need to make 
changes in 4 places.

I said the saving was ~ 40%, in fact it's ~75-80%

First wrong thing - you can't just casually write into  "byte X of tmp". 
if X is greater than the current length of tmp, then this simply appends 
a single byte. So you need to pre-fill the variable that holds the bytes.


Second wrong thing was
  put "a" into byte X of np
that should be
  put numtobyte(66) into byte X of np

I don't thin this *should* make much difference - but in fact it makes a 
huge difference. Not sure why - I suspect a bug  I'll look at it 
some more and hopefully submit a bug report later.


Third wrong thing -  I wasn't properly calculating latter set of primes.

Fourth wrong thing - I was running the wrong test stack :-)

Fifth additional minor tweak - there's no need for the array 'p'; all it 
was used for was extracting the keys, sorting them and using that to 
start the textual list of results. Better to just put the confirmed 
primes into the textual list.


So - fixing all those gives code that runs about 75-80% faster. See 
revised code below.


Now off to try a different, perhaps crazy, idea :-)

Code - sorry about the formatting ...


on mouseUp

local T

put the long seconds into T

repeat with c = 1 to 2

get get_primes(1000)

end repeat

put "button Found" && the number of lines in it && "primes in" && the 
long seconds - T && "seconds"  after fld "F"


end mouseUp

function get_primes n

local mroot, np, R

repeat with i = 1 to n

put numtobyte(66) into byte i of np

end repeat

if n < 2 then return empty

if n = 2 then return 2

put trunc(sqrt(n)) - 1 into mroot

repeat with i = 3 to mroot step 2

if byte i of np = "a" then next repeat

-- put TRUE into p[i]

put i  after R

repeat with j = i*i to n step i

put numtobyte(65) into byte j of np

end repeat

end repeat

-- put 2 & cr & the keys of p into R

-- sort lines of R numeric

repeat with i = mroot + (mroot + 1) mod 2 to n - 1 step 2

if byte i of np = numtobyte(66) then put i & CR after R

end repeat

return R

end get_primes


-- Alex.

___
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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Richard Gaskin via use-livecode

Mark Waddingham wrote:

> I think it might be quite unique amongst x-talks in another way too...
>
> How much of any of the others were written in themselves?

Not many.  Toolbook, Gain Momentum, and SuperCard are the only ones I 
can think of beyond LC that had enough confidence in their tooling to 
use it to make their tooling.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Mark Waddingham via use-livecode
I think it might be quite unique amongst x-talks in another way too...

How much of any of the others were written in themselves?

Mark.

Sent from my iPhone

> On 6 Aug 2018, at 13:26, Richard Gaskin via use-livecode 
>  wrote:
> 
> It isn't.  SuperCard is available exclusively for macOS.  There was an effort 
> in the mid-90s to port to Windows, but funding dried up before it was 
> completed so no useful version ever saw the light of day.
> 
> Toolbook is also single-platform, Windows-only.
> 
> But most of the others were cross-platform to varying degrees:  OMO and Plus 
> were Mac and Windows, Gain Momentum was Unix and Windows, SenseTalk ran on 
> Mac, Windows, and Unix.
> 
> LC is unique in its expansion to mobile, though.  And today, even looking 
> beyond xTalks, I don't see any other scripting tool with integrated GUI 
> elements available for as many platforms.
> 
> -- 
> Richard Gaskin
> 
> Richmond Mathewson wrote:
>> How "multi" is SuperCard?
>>> On 6/8/2018 6:47 pm, Bob Sneidar via use-livecode wrote:
>>> Except for Supercard.
>>> 
>>> 
 On Aug 5, 2018, at 13:40 , Alejandro Tejada via use-livecode >>> at lists.runrev.com> wrote:
 
 LiveCode is multiplatform and this single fact
 set it apart from all previous x-talk languages.
> 
> 
> ___
> 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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Richmond Mathewson via use-livecode

Oh, Yes, ToolBook . .

I had to work with ToolBook in 1998 when I was at the UAE University in 
Al Ain, UAE, making EFL "stuff".


Far, far less easy-going than HyperCard.

Sheikh Yer-Bomboms, the chancellor of the University (a man who was 
pointed on merit:
the merit of being one of the sons of Sheikh Zayed al-Nahyan), suddenly 
decided in 1998 that we'd chuck out all
the Macs running system 8 we'd just spent 4 months setting up and 
authoring EFL-ware for with HyperCard

and replace them with IBM-compats running Windows NT.

So, when I wasn't teaching women/girls whose faces I couldn't see, I was 
sitting between a Macintosh and a PC trying to

reimplement all the HyperCard offerings in ToolBook.

This was a major "fag" as a lot of what I had got going in HyperCard (3D 
models of filing cabinets popping open their

draws to reveal Quicktime movies) just did not seem possible with ToolBook.

Arriving in St. Andrews, in Scotland, in 2000, hired to author EFL-ware 
for several Mac labs (which I never did as they
redirected my efforts & we had a fight involving the teachers' Union and 
so on), I discovered Metacard, and less than 2 weeks later found

Runtime Revolution 1.1.1.

At the risk of sounding extremely corny, after 2 sweaty years with 
Toolbook, RunRev was almost like returning home.


From what I have seen recently, ToolBook seems to have "degenerated" 
from a "proper" programming IDE into some sort

of "PowerPoint on Steroids" for business types.

Richmond.

On 6/8/2018 9:26 pm, Richard Gaskin via use-livecode wrote:
It isn't.  SuperCard is available exclusively for macOS.  There was an 
effort in the mid-90s to port to Windows, but funding dried up before 
it was completed so no useful version ever saw the light of day.


Toolbook is also single-platform, Windows-only.

But most of the others were cross-platform to varying degrees: OMO and 
Plus were Mac and Windows, Gain Momentum was Unix and Windows, 
SenseTalk ran on Mac, Windows, and Unix.


LC is unique in its expansion to mobile, though.  And today, even 
looking beyond xTalks, I don't see any other scripting tool with 
integrated GUI elements available for as many platforms.




___
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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread Sannyasin Brahmanathaswami via use-livecode
On 8/6/18 7:29 AM, zryip theSlug via use-livecode wrote:
> Bob,
>
> A column template exists for each column of a dg table, so you can use any
> control you want inside a datagrid column, including widgets.
>
> Here is a link to a DGH's screenshot . On the left, we have properties for
> a column (row or header). This is a datagrid table with two visible
> columns. The second column is displaying checkboxes, text, popup menus,
> images, widgets, etc depending of the property type. This is not a trick,
> this is perfectly supported by datagrid tables.
>
> https://livecode.com/wp-content/uploads/2018/06/image14-26.png
>
> On Mon, Aug 6, 2018 at 6:22 PM, Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
>> The template is like the group editor. In fact it may actually BE the
>> group editor. The behavior script determines what to do when a row is
>> drawn.
>>
>> I think the thing to understand about datagrids, table or forms, is that
>> for each array element in the data (itself an array) the template is
>> "cloned". Each row is a "clone" of the template. But for forms, the
>> behavior does not know what you want to do when the rows are created. For
>> instance, you may want to color negative numbers in red, or surround them
>> with parenthesis. You may have a button that needs to be hilited or not
>> depending on the value for that control. Perhaps you have a field that can
>> contain multiple lines of text, and you need to set the row height for each
>> row based upon the formattedHeight of that field. Or maybe show and hide
>> objects etc.
>>
>> The beauty of a form datagrid is that how each individual row gets drawn
>> is entirely under your own programmatical control. A table datagrid is
>> simply like a spreadsheet with fixed row heights and no support for
>> graphics or other controls.
>>
>> BTW I kinda cheated and made a way to have checkboxes for a table style
>> datagrid. I simply had a group with checkboxes overlaying a "dummy" column
>> in the datagrid. When I queried for data I put something like:
>>
>> SELECT '' AS checkmark, '' AS checkmarkvalue, * FROM customers
>>
>> This put two empty strings in my array data (I use sqlYoga so I get arrays
>> back instead of cursors, but the idea is the same). I only defined a column
>> for "checkmark", but NOT for "checkmarkvalue". This allowed me to have a
>> blank column to overlay the checkboxes on, and a hidden column to hold the
>> checkmarkvalue for each row in the datagrid data.
>>
>> Then when I populated the datagrid, I hid all the checkboxes then showed
>> each checkbox control based upon how much data was being displayed. Of
>> course, you have to account for scrolling, so that can be tricky, but it
>> was a poor man's way of adding checkboxes to a table datagrid. Others could
>> probably come up with a more elegant solution.
>>
>> Bob S
>>
>>
>>> On Aug 5, 2018, at 10:03 , Sannyasin Brahmanathaswami via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>>> I slowly studying as much as we can on the datagrid,and "digging" in it
>> with an first attempt to build a form.
>>> One thing is not clear to me.
>>>
>>> 1) Have the  WYSIG panel to build the datagrid form.
>>>
>>> 2) why then do we  have, in the Behavior Script  this handler?
>>>
>>> Isn't the layout already pre-determined in the template?
>>
>> ___
>> 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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Richard Gaskin via use-livecode
It isn't.  SuperCard is available exclusively for macOS.  There was an 
effort in the mid-90s to port to Windows, but funding dried up before it 
was completed so no useful version ever saw the light of day.


Toolbook is also single-platform, Windows-only.

But most of the others were cross-platform to varying degrees:  OMO and 
Plus were Mac and Windows, Gain Momentum was Unix and Windows, SenseTalk 
ran on Mac, Windows, and Unix.


LC is unique in its expansion to mobile, though.  And today, even 
looking beyond xTalks, I don't see any other scripting tool with 
integrated GUI elements available for as many platforms.


--
 Richard Gaskin

Richmond Mathewson wrote:

How "multi" is SuperCard?

On 6/8/2018 6:47 pm, Bob Sneidar via use-livecode wrote:

Except for Supercard.



On Aug 5, 2018, at 13:40 , Alejandro Tejada via use-livecode  wrote:

LiveCode is multiplatform and this single fact
set it apart from all previous x-talk languages.



___
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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Mark Wieder via use-livecode

On 08/06/2018 10:26 AM, Richard Gaskin via use-livecode wrote:

3. The state of the art suggests we're a long way from anything close to 
the Singularity:


Google Translate’s AI starts talking about the end of the world
 



:)



LOL. I was wondering how long before someone posted that.
And in spite of Google's "fixing" the AI translator (fun while it 
lasted) if you translate "be do be do be do be do be do be do be do" 
from Maori to English you still get "why not why do not you do it?".


Or translate "Ich bi befo" from Maori to English and get "I'm like a 
butterfly"


--
 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: DataGrid image display woes

2018-08-06 Thread Trevor DeVore via use-livecode
Yes, I did write the original Data Grid. One thing I’ve learned when
working with any code in LiveCode that is shared between objects, however,
is that when you see one object updating and none of the other objects
you’ve forgotten to add “of me”.

--
Trevor DeVore

On Mon, Aug 6, 2018 at 10:41 AM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I think Trevor wrote the original datagrid behavior, or at least was
> instrumental in it.
>
> Bob S
>
>
> > On Aug 4, 2018, at 11:17 , Brian Milby via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Wow, and Trevor knew right away... pretty impressive!
> > ___
> > 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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Richmond Mathewson via use-livecode

How "multi" is SuperCard?

Richmond.

On 6/8/2018 6:47 pm, Bob Sneidar via use-livecode wrote:

Except for Supercard.

Bob S



On Aug 5, 2018, at 13:40 , Alejandro Tejada via use-livecode 
 wrote:

LiveCode is multiplatform and this single fact
set it apart from all previous x-talk languages.


___
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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread zryip theSlug via use-livecode
Bob,

A column template exists for each column of a dg table, so you can use any
control you want inside a datagrid column, including widgets.

Here is a link to a DGH's screenshot . On the left, we have properties for
a column (row or header). This is a datagrid table with two visible
columns. The second column is displaying checkboxes, text, popup menus,
images, widgets, etc depending of the property type. This is not a trick,
this is perfectly supported by datagrid tables.

https://livecode.com/wp-content/uploads/2018/06/image14-26.png

On Mon, Aug 6, 2018 at 6:22 PM, Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> The template is like the group editor. In fact it may actually BE the
> group editor. The behavior script determines what to do when a row is
> drawn.
>
> I think the thing to understand about datagrids, table or forms, is that
> for each array element in the data (itself an array) the template is
> "cloned". Each row is a "clone" of the template. But for forms, the
> behavior does not know what you want to do when the rows are created. For
> instance, you may want to color negative numbers in red, or surround them
> with parenthesis. You may have a button that needs to be hilited or not
> depending on the value for that control. Perhaps you have a field that can
> contain multiple lines of text, and you need to set the row height for each
> row based upon the formattedHeight of that field. Or maybe show and hide
> objects etc.
>
> The beauty of a form datagrid is that how each individual row gets drawn
> is entirely under your own programmatical control. A table datagrid is
> simply like a spreadsheet with fixed row heights and no support for
> graphics or other controls.
>
> BTW I kinda cheated and made a way to have checkboxes for a table style
> datagrid. I simply had a group with checkboxes overlaying a "dummy" column
> in the datagrid. When I queried for data I put something like:
>
> SELECT '' AS checkmark, '' AS checkmarkvalue, * FROM customers
>
> This put two empty strings in my array data (I use sqlYoga so I get arrays
> back instead of cursors, but the idea is the same). I only defined a column
> for "checkmark", but NOT for "checkmarkvalue". This allowed me to have a
> blank column to overlay the checkboxes on, and a hidden column to hold the
> checkmarkvalue for each row in the datagrid data.
>
> Then when I populated the datagrid, I hid all the checkboxes then showed
> each checkbox control based upon how much data was being displayed. Of
> course, you have to account for scrolling, so that can be tricky, but it
> was a poor man's way of adding checkboxes to a table datagrid. Others could
> probably come up with a more elegant solution.
>
> Bob S
>
>
> > On Aug 5, 2018, at 10:03 , Sannyasin Brahmanathaswami via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > I slowly studying as much as we can on the datagrid,and "digging" in it
> with an first attempt to build a form.
> >
> > One thing is not clear to me.
> >
> > 1) Have the  WYSIG panel to build the datagrid form.
> >
> > 2) why then do we  have, in the Behavior Script  this handler?
> >
> > Isn't the layout already pre-determined in the template?
>
>
> ___
> 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
>



-- 
Zryip TheSlug
http://www.aslugontheroad.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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Richard Gaskin via use-livecode

Mark Waddingham wrote:

> However the reason google search can do that is because some
> programmer at google has added a hook which knows that when that
> pattern is searched for it should call a program that has been
> explicitly written which looks up the current exchange rate and
> then renders the result in a nicely formatted string which appears
> at the top of the search results.

Amen.

Before anyone gets too worshipful about AI, it may be useful to consider:

1. "AI" is being bandied about for any software that has more than three 
nested "if"s. ;)  I'm exaggerating of course, but really, software is 
just software; some is more complex than others, some useful, some mere 
flourish, and none of it models human cognitive processes particularly well.



2. One motivation for normalizing the term "AI" is to minimize liability 
exposure for wealthy corporations who deploy complex software without 
adequate testing. "It has a mind of its own" is not an allowable defense 
with any other product, and continued deification of software under the 
"AI" label risks losing sight of that.



3. The state of the art suggests we're a long way from anything close to 
the Singularity:


Google Translate’s AI starts talking about the end of the world


:)

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Bob Sneidar via use-livecode
But that too is an illusion. The mysterious servers are not really "learning". 
They are taking input and then processing it according to rules that a group of 
software developer somewhere defined. That's why the "A" in "AI" means 
"Artificial". I think (and therefore I am) we need to keep this focus, 
otherwise a lot of time and energy will be spent trying to make an inanimate 
object into a living creature that actually *can* learn. What is REALLY needed 
these days is finding a way to teach children how to learn, something modern 
school systems seem to have neglected. 

Bob S


> On Aug 5, 2018, at 15:35 , Alejandro Tejada via use-livecode 
>  wrote:
> 
> Hi Mark,
> 
>> H - I think that is missing the point about what the
>> current 'AI' technologies that exist actually do (as far as
>> I can see anyway - I'd be more than happy to be
>> proved wrong!)...
> 
> Well, the point is that all current AI technologies requires
> an internet connection to work and AI software that run
> in servers is learning thousands of new interactions
> everyday from millions active users.


___
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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Bob Sneidar via use-livecode
These are great points. This is why I say that computers don't *actually* do 
anything. All they do is arrange information in a way that humans can 
understand and act upon. That human may be a software developer who then feeds 
that information to a manufacturing device to build a widget. Or it may be 
information provided to the accountant so that a printer can actually pring the 
paychecks. 

All these are incredibly useful things, but the computer is not "doing" any 
work in terms of moving mass. And what it looks like they are doing, say flying 
an airplane or drawing a spreadsheet, is really an illusion created by a long 
string of software developers to transform information we understand into a 
binary form, make some calculations, then convery the binary information back 
to another form of information. 

Bob S


> On Aug 5, 2018, at 14:35 , Mark Waddingham via use-livecode 
>  wrote:
> 
> H - I think that is missing the point about what the current 'AI' 
> technologies that exist actually do (as far as I can see anyway - I'd be more 
> than happy to be proved wrong!)...
> 
> They are merely mappings from one form input to another form of input - they 
> themselves don't do any action - the actions still have to be implemented 
> somehow.
> 
> Alexa for example by itself does diddly-squat beyond map voice to a lower 
> level actionable command (with an element of context, certainly which makes 
> it slightly interesting) - it's the skills that people 'like us' implement 
> which actually do the thing Alexa interprets that we want to be done.
> 
> Same with google assistant, siri, wolfram alpha, even google search - I can 
> type 'what is 100 usd in gbp' and it gives me the answer.
> 
> However the reason google search can do that is because some programmer at 
> google has added a hook which knows that when that pattern is searched for it 
> should call a program that has been explicitly written which looks up the 
> current exchange rate and then renders the result in a nicely formatted 
> string which appears at the top of the search results.
> 
> Warmest Regards,
> 
> Mark.
> 
> Sent from my iPhone


___
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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread Bob Sneidar via use-livecode
The template is like the group editor. In fact it may actually BE the group 
editor. The behavior script determines what to do when a row is drawn. 

I think the thing to understand about datagrids, table or forms, is that for 
each array element in the data (itself an array) the template is "cloned". Each 
row is a "clone" of the template. But for forms, the behavior does not know 
what you want to do when the rows are created. For instance, you may want to 
color negative numbers in red, or surround them with parenthesis. You may have 
a button that needs to be hilited or not depending on the value for that 
control. Perhaps you have a field that can contain multiple lines of text, and 
you need to set the row height for each row based upon the formattedHeight of 
that field. Or maybe show and hide objects etc. 

The beauty of a form datagrid is that how each individual row gets drawn is 
entirely under your own programmatical control. A table datagrid is simply like 
a spreadsheet with fixed row heights and no support for graphics or other 
controls. 

BTW I kinda cheated and made a way to have checkboxes for a table style 
datagrid. I simply had a group with checkboxes overlaying a "dummy" column in 
the datagrid. When I queried for data I put something like:

SELECT '' AS checkmark, '' AS checkmarkvalue, * FROM customers

This put two empty strings in my array data (I use sqlYoga so I get arrays back 
instead of cursors, but the idea is the same). I only defined a column for 
"checkmark", but NOT for "checkmarkvalue". This allowed me to have a blank 
column to overlay the checkboxes on, and a hidden column to hold the 
checkmarkvalue for each row in the datagrid data. 

Then when I populated the datagrid, I hid all the checkboxes then showed each 
checkbox control based upon how much data was being displayed. Of course, you 
have to account for scrolling, so that can be tricky, but it was a poor man's 
way of adding checkboxes to a table datagrid. Others could probably come up 
with a more elegant solution. 

Bob S


> On Aug 5, 2018, at 10:03 , Sannyasin Brahmanathaswami via use-livecode 
>  wrote:
> 
> I slowly studying as much as we can on the datagrid,and "digging" in it with 
> an first attempt to build a form.
> 
> One thing is not clear to me.
> 
> 1) Have the  WYSIG panel to build the datagrid form.
> 
> 2) why then do we  have, in the Behavior Script  this handler?
> 
> Isn't the layout already pre-determined in the template?


___
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: valueDiff for arrays?

2018-08-06 Thread Mark Wieder via use-livecode

On 08/05/2018 08:26 PM, Monte Goulding via use-livecode wrote:


They are constants.. the point is in order to compare a boolean to a string you 
need to convert it to a string and therefore you do string comparison on “” v 
“false”.


Doh! Yes, I forgot again about this converting everything to strings as 
the LCD.


--
 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: valueDiff for arrays?

2018-08-06 Thread Mark Waddingham via use-livecode
Alex Tweedly didn't talk nonsense... Byte x [to y] of z is (truly) constant 
time if z is strictly a binary string.

tArray[x] is constant time if x is already a name - otherwise the string needs 
turned into a name.

If x is coming from repeat for each key x - then it will already be a name.

(Not sure if that helps!)

Mark.

Sent from my iPhone

> On 6 Aug 2018, at 05:17, Alex Tweedly via use-livecode 
>  wrote:
> 
> Earlier, Alex Tweedly said some nonsense like:
> 
>> arrays are hashed - even if quickly, while byte chunks are constant time.
>> 
>> So replace both uses of the array np with a byte chunk.
>> ...
>> 
>> Takes about 40% off the time.
>> 
>> -- Alex.
> Operator error !
> Forget what I said, it was wrong.
> 
> I'll do the test more carefully and send a report later (whether it speeds 
> the test up or not).
> 
> Alex
> 
> 
> 
> ___
> 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: [OT] The problem with programming and how to fix it

2018-08-06 Thread Bob Sneidar via use-livecode
Except for Supercard. 

Bob S


> On Aug 5, 2018, at 13:40 , Alejandro Tejada via use-livecode 
>  wrote:
> 
> LiveCode is multiplatform and this single fact
> set it apart from all previous x-talk languages.


___
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: DataGrid image display woes

2018-08-06 Thread Bob Sneidar via use-livecode
I think Trevor wrote the original datagrid behavior, or at least was 
instrumental in it. 

Bob S


> On Aug 4, 2018, at 11:17 , Brian Milby via use-livecode 
>  wrote:
> 
> Wow, and Trevor knew right away... pretty impressive!
> ___
> 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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread Sannyasin Brahmanathaswami via use-livecode
Yay! I made my first form.

Now for questions *not* covered by the lessons.

1) Is the graphic "Background" a special object? In Navigator I opened
stack

"Data Grid Temple 333"
 
directly  editing the group "Row Template". I set background graphic to
roundedRectangle, corners set 20px, and applied a linear gradiant with
nice colors. I saved the stack.

But the graphic did not change?  I *can* adjust its rect, and the
rounded corners show (appears on hilite, the it is tranparent otherwise)
and that sticks, but not linear gradient?

2) How do I make the datagrid transparent (opacity to 0).  So that
between the rows there is a margin which shows the background of the
card coming through.

BR
 



___
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


[ANN] This Week in LiveCode 140

2018-08-06 Thread panagiotis merakos via use-livecode
Hi all,

Read about new developments in LiveCode open source and the open source
community in today's edition of the "This Week in LiveCode" newsletter!

Read issue #140 here: https://goo.gl/tww8bD

This is a weekly newsletter about LiveCode, focussing on what's been
going on in and around the open source project. New issues will be
released weekly on Mondays. We have a dedicated mailing list that will
deliver each issue directly to you e-mail, so you don't miss any!

If you have anything you'd like mentioned (a project, a discussion
somewhere, an upcoming event) then please get in touch.


-- 
Panagiotis Merakos 
LiveCode Software Developer

Everyone Can Create Apps 
___
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: Getting Started with DataGrid and another datagrid form

2018-08-06 Thread Sannyasin Brahmanathaswami via use-livecode
I am at the lesson.livecode.com/m/datagrid.

They are quite thorough. Much to my chagrin, everything you need to know
is there.

 I would NOT recommend just dragging a Datagrip and "digging in" are
even using DG Helper (to start)

Read the lessons first (or at same time as you follow along in a stack.)

BR










___
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: Start using stack - Loading stack libraries

2018-08-06 Thread Brian Milby via use-livecode
On my IDE, mainstacks is currently 204. The stacks are stored in a linked list, 
so no limit other than memory and performance.

Thanks,
Brian
On Aug 6, 2018, 7:14 AM -0500, Stephen MacLean via use-livecode 
, wrote:
>
> > On Aug 6, 2018, at 8:05 AM, Paul Dupuis via use-livecode 
> >  wrote:
> >
> > On 8/5/2018 11:29 PM, Stephen MacLean via use-livecode wrote:
> > > @ Paul, they are different, based upon the type of build that needs to 
> > > happen for the source that is being looked at. The code has one handler 
> > > name that is the same (The init code in the builder), but after that the 
> > > code is different.
> >
> > Some where, you have a conditional or switch statements to decide what
> > library to load based on the "source". File I/O is always slower than
> > most anything else in a computer these days. So if you load all the
> > libraries and use the switch/if/etc. to just change what library
> > routines are called based on the "source" rather than change what is
> > read from disk, you will reduce any (if there are any) memory leaks
> > issues and speed up your work. It's up to you as I, of course, have no
> > idea what your code looks like or even what you're doing.
> >
> > I get the impression that each library has many routines that have the
> > same name (as in other libraries) but do different things. It may be
> > more effort that any performance gain is worth to have to rename all
> > those routines and adjust code so they can be all loaded at once.
>
> You are correct, same name, but do different things. Each has routines that 
> are self-contained, and only rely on core functions that are at the main 
> stack level.
>
> I’ve read that there is something like a 50 stack limit that can be loaded at 
> one time, which is why I initially went this way. Do you know if that is 
> still the case?
>
> >
> > Ultimately, the best way to determine if your approach to loading and
> > unloading libraries in volume is to construct a quality assurance test -
> > get or generate a while pile of "sources" and run them through on a test
> > system and see what happens.
> >
>
>
> In this process now and hoping to see good results with the way it is, but 
> always looking to improve.
>
> Thx!
>
> Steve
>
>
>
> ___
> 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: Start using stack - Loading stack libraries

2018-08-06 Thread Stephen MacLean via use-livecode

> On Aug 6, 2018, at 8:05 AM, Paul Dupuis via use-livecode 
>  wrote:
> 
> On 8/5/2018 11:29 PM, Stephen MacLean via use-livecode wrote:
>> @ Paul, they are different, based upon the type of build that needs to 
>> happen for the source that is being looked at. The code has one handler name 
>> that is the same (The init code in the builder), but after that the code is 
>> different.
> 
> Some where, you have a conditional or switch statements to decide what
> library to load based on the "source". File I/O is always slower than
> most anything else in a computer these days. So if you load all the
> libraries and use the switch/if/etc. to just change what library
> routines are called based on the "source" rather than change what is
> read from disk, you will reduce any (if there are any) memory leaks
> issues and speed up your work. It's up to you as I, of course, have no
> idea what your code looks like or even what you're doing.
> 
> I get the impression that each library has many routines that have the
> same name (as in other libraries) but do different things. It may be
> more effort that any performance gain is worth to have to rename all
> those routines and adjust code so they can be all loaded at once.

You are correct, same name, but do different things. Each has routines that are 
self-contained, and only rely on core functions that are at the main stack 
level.

I’ve read that there is something like a 50 stack limit that can be loaded at 
one time, which is why I initially went this way. Do you know if that is still 
the case?

> 
> Ultimately, the best way to determine if your approach to loading and
> unloading libraries in volume is to construct a quality assurance test -
> get or generate a while pile of "sources" and run them through on a test
> system and see what happens.
> 


In this process now and hoping to see good results with the way it is, but 
always looking to improve.

Thx!

Steve



___
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: Start using stack - Loading stack libraries

2018-08-06 Thread Paul Dupuis via use-livecode
On 8/5/2018 11:29 PM, Stephen MacLean via use-livecode wrote:
> @ Paul, they are different, based upon the type of build that needs to happen 
> for the source that is being looked at. The code has one handler name that is 
> the same (The init code in the builder), but after that the code is different.

Some where, you have a conditional or switch statements to decide what
library to load based on the "source". File I/O is always slower than
most anything else in a computer these days. So if you load all the
libraries and use the switch/if/etc. to just change what library
routines are called based on the "source" rather than change what is
read from disk, you will reduce any (if there are any) memory leaks
issues and speed up your work. It's up to you as I, of course, have no
idea what your code looks like or even what you're doing.

I get the impression that each library has many routines that have the
same name (as in other libraries) but do different things. It may be
more effort that any performance gain is worth to have to rename all
those routines and adjust code so they can be all loaded at once.

Ultimately, the best way to determine if your approach to loading and
unloading libraries in volume is to construct a quality assurance test -
get or generate a while pile of "sources" and run them through on a test
system and see what happens.



___
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: valueDiff for arrays?

2018-08-06 Thread Alex Tweedly via use-livecode

Earlier, Alex Tweedly said some nonsense like:


arrays are hashed - even if quickly, while byte chunks are constant time.

So replace both uses of the array np with a byte chunk.
...

Takes about 40% off the time.

-- Alex.

Operator error !
Forget what I said, it was wrong.

I'll do the test more carefully and send a report later (whether it 
speeds the test up or not).


Alex



___
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: valueDiff for arrays?

2018-08-06 Thread Alex Tweedly via use-livecode

arrays are hashed - even if quickly, while byte chunks are constant time.

So replace both uses of the array np with a byte chunk.

i.e.

if byte i of np = "n" then next repeat

...

put "n" into byte j of np

Takes about 40% off the time.

-- Alex.



On 06/08/2018 03:36, Richard Gaskin via use-livecode wrote:

Mark Waddingham wrote:

> Richard wrote:
>>
>> Thinking about performance, I wonder if there's anything from some of
>> the changes that have boosted PHP 7's performance so far above its
>> earlier versions which may be relevant for LC:
>> 
https://www.reddit.com/r/PHP/comments/3q2brz/how_is_php_7_twice_as_fast/

>
> I'd actually be really interested in a direct speed comparison between
> exactly equivalent operations in PHP7 and LC.

Geoff Canyon and I corresponded on this back in March.  I don't think 
he'll mind me sharing some of the relevant parts of his test:


---  from GC 

on mouseUp
   put the long seconds into T
   repeat with c = 1 to 10
  get get_primes(1000)
   end repeat
   put "Found" && the number of lines in it && "primes in" && the long 
seconds - T && "seconds"

end mouseUp

function get_primes n
   if n < 2 then return empty
   if n = 2 then return 2
   put trunc(sqrt(n)) - 1 into mroot
   repeat with i = 3 to mroot step 2
  if np[i] > 0 then next repeat
  add 1 to p[i]
  repeat with j = i^2 to n step i
 add 1 to np[j]
  end repeat
   end repeat
   put 2 & cr & the keys of p into R
   sort lines of R numeric
   repeat with i = mroot + (mroot + 1) mod 2 to n - 1 step 2
  if np[i] is empty then put cr & i after R
   end repeat
   return R
end get_primes

And that takes about fifteen minutes to run on my 2013 MacBook Pro, 
where the slowest performer he's working with takes less than 30 
seconds, and PHP 7 runs in under 7 seconds. Any ideas where I'm 
deviating in my implementation compared to his? Here's the latest 
version of his test that I found:


https://blog.famzah.net/2016/09/10/cpp-vs-python-vs-php-vs-java-vs-others-performance-benchmark-2016-q3/ 



-




___
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