Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-14 Thread Erling Hellenäs
I can't verify that. For some values it is faster, yes, but it seems measurements with 1 000 000 items shows your original assumption was correct. See below. /Erling NB. Find the longest ascending subsequence in y NB. y is a list of numbers NB. Result is indexes of the values that form the la

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-14 Thread 'Mike Day' via Programming
It depends on both m and n in ?m#n Also, note that it's better to move definition of the input outside the time (and space) test. Using ?. to fix the samples, and 1 ts to save waiting on longer arguments: ts each '#longascseq1 q';'#longascseq2 q'[q =: ?.~10NB. set outside +---

Re: [Jprogramming] Counting characters

2016-09-14 Thread 'Pascal Jasmin' via Programming
simple rules, think only of fork (not hook). So odd number of tines, and (0 index) odd verbs are dyads, evens are ambivalent (same valence as whole verb) as an exercise, look at the hook rule, and write an equivalent fork for it. [: will look the most like explicit. in a fork, its only vali

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-14 Thread Erling Hellenäs
Any ideas about how you could make a substantially faster tacit solution to this problem or how you could make this solution substantially faster? /Erling On 2016-09-13 18:17, Erling Hellenäs wrote: Hi all ! My first idea only took me down to 1 second for 10 000 numbers, 25 times longer tha

Re: [Jprogramming] Counting characters

2016-09-14 Thread Roger Hui
The original question is about composing functions, but if you are really trying to count characters there are much more efficient ways. For example: x=: 'abcdefghijklmnopqrstuvwxyz' y=: a.{~ 1e6 ?@$ #a. c=: <: (#x) {. #/.~ x,y $c 26 c 4019 3829 3893 3912 3889 4020 3965 3936 3960 3

Re: [Jprogramming] Greatest Increasing Subsequence

2016-09-14 Thread 'Mike Day' via Programming
I suspect it's pretty near optimal. The wikipedia article points at Fredman's paper: http://www.sciencedirect.com/science/article/pii/0012365X7590103X analysing an algorithm of Knuth's. He shows that it performs better than n log2(n) - n log2 log2 (n) + O(n) rather than the O(n logn) cited