Re: [Jprogramming] A little question

2013-12-22 Thread Marshall Lochbaum
The expression (<".x{>y) opens all of y, then selects, executes, and boxes. The end result is a single box. You're looking for numerize =: 3 : '(".&.> x{y) x} y' . This function selects the appropriate boxes, then opens each box, executes and closes the box. You can compare the right arguments t

Re: [Jprogramming] More-than-binary Gray codes

2013-12-22 Thread Raul Miller
One issue is this: i.@<.&.(3&^.) Notice that 3%^. is the right verb for the under conjunction. There's no simple way of passing the 3 in as an argument to that verb. Does that make sense? Thanks, -- Raul On Sun, Dec 22, 2013 at 10:28 PM, Devon McCormick wrote: > Hi Everybody - > > I was

[Jprogramming] More-than-binary Gray codes

2013-12-22 Thread Devon McCormick
Hi Everybody - I was recently thinking of a possible use for Gray codes that work in a base greater than 2. Searching my mail on this, I was led back to a discussion from 2006 that Dan Bron had kicked off by offering the generation and conversion of Gray codes as a puzzle. R. E. Boss, among othe

Re: [Jprogramming] Tacit series

2013-12-22 Thread Henry Rich
It's a matter of taste whether expt is an improvement over exp. Me, I think what you'd really like is to encapsulate the expansion while allowing for a different multiply; in other words, to write an adverb. I would go for NB. Adverb to take exponential using the power-series definition NB. u

Re: [Jprogramming] Tacit series

2013-12-22 Thread km
Henry, verb expt below is what I came up with. A slight modification will give me what I really want, a tacit exponential for quaternions represented as complex pairs. --Kip clean =: (* *!.1e_14@|)"0&.+. exp =: 3 : 0 os =. 0 s =. 1 k =. 0 t =. 1 while. s ~: os do. os =

Re: [Jprogramming] A little question

2013-12-22 Thread Devon McCormick
If you break down what's happening inside the function with your example: 1 2{arg +--+-+ |266239|1| +--+-+ >1 2{arg 266239 1 ".>1 2{arg 266239 1 So this vector gets boxed and put into both places. If you allow for multiple elements in "x", you might do something like this: ("

[Jprogramming] A little question

2013-12-22 Thread Ricardo Forno
I have this little function: numerize =: 13 : '(<".x{>y)x}y' It makes numeric the contents of the xth box of the y argument. For example, let b: b ┌─┬──┬─┐ │ALPHA│266239│1│ └─┴──┴─┘ 1 numerize b makes numeric the middle box. Why does it not work with the last two elements of b,

Re: [Jprogramming] Tacit series

2013-12-22 Thread Jose Mario Quintana
Actually, having a changing item, for example a counter, might be sometimes advantageous since a verb ( u^:v^:_) can also terminate even if v is 1 (true) when u converges (that is, if the result of u matches its previous result) which could have adverse unintended consequences (Henry, I know you k

Re: [Jprogramming] Tacit series

2013-12-22 Thread Dan Bron
Kip wrote: > interested in tacitly terminating a series when > its partial sums stop changing. Below is one approach to mechanically transliterate your explicit exp to a tacit version, expT. Short story: we use ^:_ to calculate values of the series until it converges. And, in place of temporar

Re: [Jprogramming] Tacit series

2013-12-22 Thread Raul Miller
I think I understand what you are saying. http://www.jsoftware.com/jwiki/Essays/Extended%20Precision%20Functions Nevertheless, I'm a bit concerned about the way you have stated your point. Consider, for example: (%!i.432x)&p. x:1e6 Like you mention in the second half of your paragraph, the is

Re: [Jprogramming] Tacit series

2013-12-22 Thread Roger Hui
This is what the Extended Precision Functions page does with more finesse. For example, computing ^1e6 with your approach would take many terms. Instead, one can scale the argument so that you only need to do the series on a very restricted domain (for exp, bounded by 2%~^.2, approximately 0.35),

Re: [Jprogramming] Tacit series

2013-12-22 Thread Raul Miller
Or, more generally, you need to iterate on an item where k,s, and t are functions of that item, as is the stopping condition. A boxed list is one example of this kind of approach but it need not be the only example. If nothing else, since k,s, and t are all numeric, I'm not sure I see the need fo

Re: [Jprogramming] Tacit series

2013-12-22 Thread Henry Rich
I can't figure out a pleasing way to do this. You need 4 things: k,s,y,t. 3 of these change. So, you need to join them as a boxed list and then iterate, but you can't iterate until they stop changing, because the iteration number always changes. t also changes. Yuck. Henry Rich On 12/22

Re: [Jprogramming] Tacit series

2013-12-22 Thread Raul Miller
On Sun, Dec 22, 2013 at 10:50 AM, Roger Hui wrote: > I expect exp can be improved. The details are left as an exercise for the > reader. :-) And, perhaps, the concept of what "improved" means can be an exercise for the reader? Here, I'll optimize for useless accuracy (or at least accuracy which

Re: [Jprogramming] Tacit series

2013-12-22 Thread Roger Hui
I expect Kip knows all that, but is interested in exactly what he said, tacitly computing a function by a series. I have an example of doing what you said, which is deciding how many terms are needed and then only computing those terms. See: http://www.jsoftware.com/jwiki/Essays/Extended_Precisi

Re: [Jprogramming] Tacit series

2013-12-22 Thread Roger Hui
A while loop can be effected tacitly by f^:g^:_, which says do f while g is true. Therefore, g=: , %@!@# g '' 1 g g '' 1 1 g g g '' 1 1 0.5 g^:10 '' 1 1 0.5 0.17 0.0416667 0.0083 0.00138889 0.000198413 2.48016e_5 2.75573e_6 g^:10 ]0$1x 1 1 1r2 1r6 1r24 1r120 1r720 1r5040

Re: [Jprogramming] Tacit series

2013-12-22 Thread Bo Jacoby
Don't be interested in terminating a series when its partial sums stop changing. If the partial sums never stop changing, then the program cycles, which you don't want. Make up your mind how many terms you want to include in the worst case, and then use that number of terms in any case.  That le

Re: [Jprogramming] Tacit series

2013-12-22 Thread R.E. Boss
See the examples in http://www.jsoftware.com/help/dictionary/d202v.htm R.E. Boss (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics ) > -Original Message- > From: programming-boun...@forums.jsoftware.com [mailto:programming- > boun...@forums.jsoftware.com] On Behal

Re: [Jprogramming] Tacit series

2013-12-22 Thread km
Thanks, Raul, for a cool solution. I'm still interested in tacitly terminating a series when its partial sums stop changing. --Kip Sent from my iPad > On Dec 22, 2013, at 12:34 AM, Raul Miller wrote: > > ^ 2 > 7.38906 > (%!i.40) p. 2 > 7.38906 > (^ = (%!i.40)&p.) 0j1p1 > 1 > > I'd ju