Re: [Jprogramming] A Complaint with Format

2016-09-23 Thread Peter B. Kessler
Have the input be your verb, a 1, and the 2-5 digit number. E.g., instead of entering 012, the user enters 1012. Then you can strip off the leading 1 after you have converted the input to a string. Some users will forget, and there's no way to know if a leading 1 should have been entered as

Re: [Jprogramming] Morning Mystery

2016-02-25 Thread Peter B. Kessler
Thanks for noticing the golden ratio, which allows 2%1+%:5 0.618034 3 nouns, 3 verbs: 7 characters. ... peter On 02/25/16 01:25 AM, Ben Gorte - CITG wrote: I noticed a golden ratio. %/({:,+/)^:(3*4*5)[1 2 NB. 6, 7, 8 and 9 not needed 0.618034

Re: [Jprogramming] This year is one of a kind...

2015-12-28 Thread Peter B. Kessler
I don't know how to use symbols above 'z' for digits in higher bases, but 55#.36 36 2016 so if '36' were one symbol, '36 36' would be a palindrome even without leading zeroes. ... peter On 20151228 8:36 AM, greg heil wrote: Happy 3b002202200 ! ~gre

Re: [Jprogramming] count of consecutive 1s

2014-10-24 Thread Peter B. Kessler
Similar, but exploiting Oblique instead of Suffix-Under-Reverse (# {. ([ * +)//. & (]"0 1/~)) 1 0 1 1 1 1 0 1 1 0 1 2 3 4 0 1 I like this because I can watch the intermediate values flow from right to left. And I can stare at the result of (]"0 1/~) until I understand what

Re: [Jprogramming] Protect the Almond Cookies

2014-10-03 Thread Peter B. Kessler
Are only 2-dimensional boxes permitted? That is, are these allowed? 2 2 3 $ <'0' +-+-+-+ |0|0|0| +-+-+-+ |0|0|0| +-+-+-+ +-+-+-+ |0|0|0| +-+-+-+ |0|0|0| +-+-+-+ 2 3 2 $ <'0'

Re: [Jprogramming] Challenge 14; Colorful Creations

2014-03-31 Thread Peter B. Kessler
(Just to you, because I don't want to expose my ignorance any further than I have to.) I can see the value (pun intended) of having a grayscale palette that shades smoothly from white to black. For example if I'm preparing a bar chart for publication: I want to pick N different shadings that

Re: [Jprogramming] J as an interviewing tool

2014-03-27 Thread Peter B. Kessler
I came up with (%~ */) 4 3 2 8 48 64 96 24 but I think your solution is more readable. ... peter On 20140327, 1:10 PM, Dan Bron wrote: Oh, I like this game! (*/ % ]) 4 3 2 8 48 64 96 24 (*/@#~1-=@i.) 4 3 2 8 48 64 96

Re: [Jprogramming] a good bar bet!

2014-03-07 Thread Peter B. Kessler
On 03/06/14 17:10, Roger Hui wrote: Probably not. It's not related to the problem of finding the minimum that I know of. It's the general problem of how you avoid initializing a large but sparse array. Recently, I did use the idea in a case of x i. y (you know, the problem I've been working on

Re: [Jprogramming] a good bar bet!

2014-03-05 Thread Peter B. Kessler
For the minimum in a small universe, use your "broken" sorting code (:-) I4 count[M]; memset(count,0x00,sizeof(count)); for(i=0;i Good answers. For /:~x vs. g{x, the explanations are: - Indexing must check for index error. Sorting does not. - Indexing uses random read acces

Re: [Jprogramming] What does this do?

2014-02-20 Thread Peter B. Kessler
A more interesting question is: Why did you think of doing it that way? The really interesting question is: How can I learn to think that way? ... peter On 02/20/14 12:42, Roger Hui wrote: % 1 +. (+%)/\ 100 $ 1x

Re: [Jprogramming] The Accessible Dictionary released

2014-01-22 Thread Peter B. Kessler
n, the titles are shortened to "Vocabulary ...", which doesn't help at all.) ... peter On Wed, Jan 22, 2014 at 1:46 PM, Peter B. Kessler < peter.b.kess...@oracle.com> wrote: Would it make sense to put the ranks in place of the operands? Monads with one rank o

Re: [Jprogramming] The Accessible Dictionary released

2014-01-22 Thread Peter B. Kessler
On 01/22/14 05:43, Ian Clark wrote: Re Rank Information on Nuvoc portal page: I've implemented something which I hope fits the bill for now, until someone can come up with a technically satisfying alternative. Initially the Nuvoc page comes up as-is, but a prominent link lets you see an alternat

Re: [Jprogramming] Times Table Therapy

2013-12-05 Thread Peter B. Kessler
Does it make it clearer to write the monadic and dyadic forms together with the "long-form" of Monad-Dyad? E.g., NB. Define a "table" adverb. The monad is reflexive. h=: 1 : 0 y u/ y : x u/ y ) NB. An example use as a monad.

Re: [Jprogramming] An essay on boxed vs unboxed table performance

2013-09-12 Thread Peter B. Kessler
I don't like losing data to averages, so I have TimeToExecute=: verb define NB. The number of seconds to compute x executions of y (which must be quoted to delay execution). 1 TimeToExecute y : (x $ 1) (6!:2) y ) and then I can run, for example 10 Ti

Re: [Jprogramming] newbie help: how to avoid division by zero

2013-05-17 Thread Peter B. Kessler
I'm also a J-newbie, but I would make up a new verb that did "divide, but not by zero". I can distinguish between zero and non-zero by Bonding[0] a 0 to Equal[1] 0&= y 1 0 0 0 I know about Agenda[2] which selects a verb from a gerund[2]. E.g., x ( + ` - ` * ` % @. 3)

Re: [Jprogramming] i.0 0[A[B

2013-04-18 Thread Peter B. Kessler
http://www.jsoftware.com/help/jforc/declarations.htm mentions The display of a rank-2 array with no items is different: here we have zero lists, so we should expect no lines at all. This is indeed what happens: 0 0$0 (there is no blank line). This is the result you should pro

Re: [Jprogramming] J and APL symbols

2013-04-04 Thread Peter B. Kessler
I hope you can make this kind of change uniform, so that if I were debugging or tracing, etc., I saw my program in the same character set that I used to write my program. Otherwise I can't use the powerful parallel processor that is my vision system to match things up.

[Jprogramming] Errata: Example for "H. Frets and Scripts"

2013-03-25 Thread Peter B. Kessler
I happened to be reading H. Frets and Scripts http://www.jsoftware.com/help/dictionary/dicth.htm and was trying to work out the example s=: 0 : 0 y*%:y : x*!y ) a. i. sThe character with index 10 marks the end of each line 121 46 4

Re: [Jprogramming] What are 0: 1: and 2: ?

2013-03-14 Thread Peter B. Kessler
http://www.jsoftware.com/help/dictionary/dconsf.htm ... peter On 03/14/13 18:40, Alex Giannakopoulos wrote: I saw these operators, 0: and 2: in some code, and I can't quite make out what they do, nor can I find any documentation. Any suggestions?

Re: [Jprogramming] Boxed Display

2013-02-08 Thread Peter B. Kessler
That looks like you changed your box-drawing characters setting with (9!:7). The Dictionary[1] says the default is (9!:6) '' +|- but in fact for j64-701 they are (9!:6) '' ??? which don't work as well in ASCII email. ... peter [1] h

Re: [Jprogramming] atop continues to puzzle me

2013-01-02 Thread Peter B. Kessler
Am I correct that in your example, you are using Open (>) just for its rank (monadic 0), and not for its verb (the inverse of Box)? That is < @ i. @ ]"0 ( 2 3 4 ) +---+-+---+ |0 1|0 1 2|0 1 2 3| +---+-+---+ would work as well. (Parens around the argument are nee

Re: [Jprogramming] Deduction, Induction, and Prediction.

2012-12-21 Thread Peter B. Kessler
Brian Schott wrote: Why do you use `:3 and not / in deduce? I have always thought the former was ugly. Thanks for making me look at the Dictionary for m`:n (Evoke Gerund). Is there some point in having that entry show the equivalence of, for example, + ` - ` * ` % `:0 i. 5 0 1 2

Re: [Jprogramming] convert 0,1 coding to _1,1

2012-12-10 Thread Peter B. Kessler
Double the distance between 0 and 1, and then shift those points left one unit on the number line. am2=: ((-&1) @ +:) am2"1] 2 6 ?.@$ 2 _1 _1 _1 _1 1 _1 _1 _1 _1 1 1 _1 Does that make sense? ... peter Brian Schott wrote: Is there a better way than

Re: [Jprogramming] @: and capped fork

2012-11-30 Thread Peter B. Kessler
And having read that statement about parentheses, you then come to the bottom of http://www.jsoftware.com/help/jforc/common_mistakes.htm where it says As a stopgap, you can imagine that each name's value is enclosed in parentheses before it is substituted. This still isn't exactly right

Re: [Jprogramming] Matrix Transformations based on local submatrices

2012-11-19 Thread Peter B. Kessler
Alex Giannakopoulos wrote: On 17 November 2012 02:39, Raul Miller wrote: On Fri, Nov 16, 2012 at 11:53 AM, Alex Giannakopoulos then cheap tricks like "padding" to read will have to be discarded, and something more serious adopted. (I mean, you're not going to pad a 3-d cube with 6 copies of

Re: [Jprogramming] Matrix Transformations based on local submatrices

2012-11-16 Thread Peter B. Kessler
Raul Miller wrote: On Thu, Nov 15, 2012 at 7:06 PM, Alex Giannakopoulos Nice "torus-pad" ([:|:{:,]{.)^:2 Or, more generally: (0 |:{:,],{.)^:(#@$) Also, here's a general "fill pad": ((_1 ["0 $) |. ({.~ 2 +$)) That said: generality can be good for insight, and in utility contexts, but

Re: [Jprogramming] Arc consistency in J

2012-11-08 Thread Peter B. Kessler
The shape of the arguments to the verb that's being inserted is 3x4, so when that verb returns an atom, as dyadic + does, the shape of the result is 3x4. But dyadic ? (Deal[1]) doesn't return an atom: it returns a list of the number of items of its left argument. So for each of the 3x4 applic

Re: [Jprogramming] Arc consistency in J

2012-11-06 Thread Peter B. Kessler
[: │-- / --- < --++- ] L- i. In situations like this I guess timing would be the referee. Linda -Original Message- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Peter B. Kessler Sent: T

Re: [Jprogramming] Arc consistency in J

2012-11-06 Thread Peter B. Kessler
Linda Alvord wrote: This sequence has a few problems: A=. ? (2$n)$2 NB. generate random matrix of [0,1] A=. A *. (i.n) I have no idea where this fits in the scheme of sudoku solvers, but the repeated use of "i. y" in your definition of "f" seems awkward, and the repeated use of "f n"

Re: [Jprogramming] macosx j602

2012-10-24 Thread Peter B. Kessler
Kamakura 2012/10/25 Peter B. Kessler (Oh boy, something I know about: Java versions and variants. :-) The "mixed mode" in the output of "java -version" means that the Java HotSpot virtual machine runs Java code first by interpreting it, and then by compiling the Java code that

Re: [Jprogramming] stitching matrices

2012-10-24 Thread Peter B. Kessler
Spectacular! I was curious what "nc" was, because *I* don't remember defining that verb. I discovered nc 4!:0 That is, nc is "pre-defined" as a name for 4!:0. 4!:0 is the foreign function verb that returns the "class" of a boxed name as an integer.[1] Is there a list of pre-define

Re: [Jprogramming] macosx j602

2012-10-24 Thread Peter B. Kessler
(Oh boy, something I know about: Java versions and variants. :-) The "mixed mode" in the output of "java -version" means that the Java HotSpot virtual machine runs Java code first by interpreting it, and then by compiling the Java code that runs a lot (the hot spots). The variants are: (1) th

Re: [Jprogramming] stitching matrices

2012-10-23 Thread Peter B. Kessler
Raul Miller wrote: Also, I was noticing that we do not have any editor support for recognizing or moving between matching parenthesis, and that would be handy when refactoring code like this. It's almost enough to make me want to start using emacs again (but I stopped because of RSI issues

Re: [Jprogramming] Partitioning a string into unequal-length parts

2012-10-09 Thread Peter B. Kessler
Key (/.) is cool! For the boolean case, plus-insert-prefix (+/\) is your friend b =: 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 +/\ b 0 0 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 (+/\b) http://www.jsoftware.com/docs/help701/dictionary/d421.htm Christoph von

Re: [Jprogramming] Flattening a list containing boxed elements

2012-09-10 Thread Peter B. Kessler
I'm still at the stage where I have to read the dictionary entry for most of the verbs, so I'm not even in the slow lane yet. Looking at Stitch (dyadic ,.)[1] I was reminded of the explanation of u"_1, which suggested using Link (dyadic ;)[2] g =: }. @ (; @ (;"_1)) ' ' g

Re: [Jprogramming] Scalar to Vector - Yet again

2012-09-04 Thread Peter B. Kessler
Henry Rich wrote: ''$, '' |length error This one doesn't work when applied to an empty. Sometimes that's desirable. The others work on empties. Note that '' ($,) A has the same result as '' $ , A but the former version is backed by special code & doesn't actually do the enfile.

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

2012-08-21 Thread Peter B. Kessler
http://www.jsoftware.com/help/dictionary/d522.htm is the dictionary entry for {: (Tail). The title of the page is given in the HTML source as where it probably should say {: Tail It would be nice if it could be fixed, since I tend to have a lot of tabs up on various dictionary pages,

Re: [Jprogramming] Determining an 'alternating' binary array

2012-08-10 Thread Peter B. Kessler
In response to my request for a solution to the alternating binary array problem that uses J's Sequential Machine (;:) verb, Raul Miller posted this[1] Here's an implementation which uses ;: smalt=: 12 > (3;1,~&>0 1 2 3,1 3 2 3,2 1 3 3,:3)&;:@:#.@|: I thought it would be worth writing Raul's

Re: [Jprogramming] Miscellaneous J Questions

2012-08-08 Thread Peter B. Kessler
The file:/// version is available on my laptop when I'm not connected to the network (e.g,. while traveling). ... peter Ian Clark wrote: All the J Help is replicated online at: http://www.jsoftware.com/help/ It should be identical to the locally installed J Help, at: fi

Re: [Jprogramming] Determining an 'alternating' binary array

2012-07-30 Thread Peter B. Kessler
Thank you, thank you, thank you! I'll digest your mail, spend a few more productive hours with the Dictionary, and send comments, but this looks like the kind of explanation I've been wanting. ... peter Raul Miller wrote: On Mon, Jul 30, 2012 at 4:12 P

Re: [Jprogramming] Determining an 'alternating' binary array

2012-07-30 Thread Peter B. Kessler
R.E. Boss wrote: My 2 cents: (>./-<./)+/\+/1 _1 *A 1 (>./-<./)+/\+/1 _1 *B 2 So A qualifies, B does not. R.E. Boss This doesn't address the case where both inputs have 1's in the same column ]C=:2 5 $ 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 1 0 (>./