Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Raul Miller
On Thu, Aug 23, 2012 at 4:05 PM, Skip Cave wrote: > I like your monadic seq verb, as it duplicates the Octave function, > including the argument sequence. I do find it interesting that a tacit verb > requires many more characters than the explicit definition. I usually > expect the opposite. Taci

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Brian Schott
The j stdlib has the verb steps. steps {. + (1&{ - {.) * (i.@>: % ])@{: steps 1 10 3 1 4 7 10 -- (B=) -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Skip Cave
Raul, I like your monadic seq verb, as it duplicates the Octave function, including the argument sequence. I do find it interesting that a tacit verb requires many more characters than the explicit definition. I usually expect the opposite. Skip On Thu, Aug 23, 2012 at 1:56 PM, Raul Miller wrot

Re: [Jprogramming] Typo in http://www.jsoftware.com/help/dictionary/d522.htm

2012-08-23 Thread Roger Hui
I will fix these when I next have time. There are a few other annoying flaws (e.g. superfluous / in d310n.htm) that need to be fixed up. On Tue, Aug 21, 2012 at 5:52 PM, Peter B. Kessler < peter.b.kess...@oracle.com> wrote: > http://www.jsoftware.com/help/**dictionary/d522.htm

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Raul Miller
On Thu, Aug 23, 2012 at 12:34 PM, Skip Cave wrote: > What I was trying to do was emulate a standard sequence function in Octave > which has the following syntax: >>> e:i:s > ans = 5.0 5.25000 5.5 5.75000 6.0 6.25000 6.5 6.75000 > 7.0 7.25000 7.5 7.75000 8.0 > > In our M

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Skip Cave
Good point, Raul. If i =. 0.27 for example, my explicit formula blows up. What I was trying to do was emulate a standard sequence function in Octave which has the following syntax: >> e:i:s ans = 5.0 5.25000 5.5 5.75000 6.0 6.25000 6.5 6.75000 7.0 7.25000 7.5 7.75000 8.000

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Raul Miller
On Thu, Aug 23, 2012 at 5:07 AM, Skip Cave wrote: > I would like to generate a vector sequence of numbers starting from s and > going to e, with increment i ... > what would the tacit form of the sequence verb look like, if we defined the > dyadic verb seq thus: > (s,e) seq i > here is an explici

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Linda Alvord
5!:5 <'randStringB' 4 : '(? y $ #x) { x' But this is not tacit so 5!:5 is of no use. Maybe 5!:5 could learn to make trees from explicit definitions. Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Linda Alvord
I just saw the advantage of the dyad definition. You can see where the variables are. Now my question is "Why would you want or need a tacit definition?". The dyad seems to be a good "human communication language". Linda -Original Message- From: programming-boun...@forums.jsoftwar

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Linda Alvord
What is the advantage of a "dyad" definition? randStringB=: 4 : '(? y $ #x) { x' rSB=: 13 :'(?y$#x){x' randStringB 4 : '(? y $ #x) { x' rSB [ {~ [: ? ] $ [: # [ L randStringB 10 DABDABDABA L rSB 10 ACBCDADDDA Linda -Original Message- From: programming-boun...

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Henry Rich
By observing that triang@i. is the same as +/\@i. we could turn Ewart's gem into rsm =: (((>. |:)@(+/) { normalrand@({: + #)@]) +/\)@i. I'm not sure that's prettier; it uses the arcane ({: + #) to do the work of a single triang; but it might be a good form for a 'symmetric matrix of anything

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Ric Sherlock
I think your analogy is very apt. IMO the first one is verbose with needless repetition, while the second is more concise and elegant. Compare randStrngC and randStrngX (or randStrngG) in the Guide I linked to earlier. The latter two do a much better job of concisely representing the processing re

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Linda Alvord
She went to the store and bought apples and bananas and oranges and grapes and cherries and pineapple. Or She went to the store and bought apples, bananas, oranges, grapes, cherries and pineapple. As you say, it is a matter of taste. Linda -Original Message- From: programming-boun...

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Ric Sherlock
I agree that "optimal" is a subjective concept - that was why I put it in quotes in my previous email. I wasn't thinking about performance when I used optimal though, (although that could also come in to it), I was talking more about how to most naturally express an algorithm. For example, when I

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Linda Alvord
Here's another look at both: 5!:4 <'f' -- 0 +- { │ L- [ +- + --+ -- ] │ +- * │ │

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Linda Alvord
I would write it from right to left: s=:2 e=:5 i=:0.25 s + i * i. 1 + (e-s) % i x=:2 5 y=:i --/x 3 y%~--/x 12 (0{x)+y*i.>:y%~--/x 2 2.25 2.5 2.75 3 3.25 3.5 3.75 4 4.25 4.5 4.75 5 f=: 13 :'(0{x)+y*i.>:y%~--/x' 2 5 f 0.25 2 2.25 2.5 2.75 3 3.25 3.5

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread bill lam
machine translation is [:-:]*>: while that from Shaw is -:@(*>:) the main difference in this case 13 : tends use [: to form a train of fork but human tends to form compound verb using @ That said, certainly some prefer [: over @. IMO 13 : is similar to google translate, it is useful but the res

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Linda Alvord
If you compare these two tacit versions for the creation of the matrix, I think my version is optimal because it is "read" from right to left. I don't care much if it or most any function is fast, as it always beats me in completing whatever it is doing. Maybe someone will write an optimizer to t

Re: [Jprogramming] Generating a sequence

2012-08-23 Thread Ric Sherlock
Here is a tacit version using close to the same algorithm that you propose below: seq=: {.@[ + ] * -~/@[ i.@>:@<.@% ] (2 5) seq 0.25 2 2.25 2.5 2.75 3 3.25 3.5 3.75 4 4.25 4.5 4.75 5 On Thu, Aug 23, 2012 at 9:07 PM, Skip Cave wrote: > I would like to generate a vector sequence of numbers

[Jprogramming] Generating a sequence

2012-08-23 Thread Skip Cave
I would like to generate a vector sequence of numbers starting from s and going to e, with increment i here is an explicit function for that: s + i * i. 1 + (e-s) % i s =. 2 e =. 5 i =. 0.25 s + i * i. 1 +(e-s) % i 2 2.25 2.5 2.75 3 3.25 3.5 3.75 4 4.25 4.5 4.75 5 what would the t

Re: [Jprogramming] Creating random symmetric matrices

2012-08-23 Thread Ric Sherlock
Hi Linda, Basically tacit definitions contain no reference to their arguments. http://en.wikipedia.org/wiki/Tacit_programming By that definition the following assignment isn't tacit because the "y" refers to the right argument. trian=: 13 :'-:y*>:y' However the resulting definition for trian