Re: [Jprogramming] J901-beta-d

2019-04-21 Thread Henry Rich
the new version. Henry Rich On 4/21/2019 2:57 PM, Eric Iverson wrote: J901-beta-d is available as a zip install package for windows/mac/linux. Get your zip install package: https://code.jsoftware.com/wiki/System/Installation/Zips After your first install of J901 beta you will be able to do

Re: [Jprogramming] Character Handling

2012-07-10 Thread Henry Rich
Have a look at /. 4 4 $ 'abcdefghijklmnop' Henry Rich On 7/10/2012 10:16 AM, Rudi Mann wrote: Ian, thanks for the solution! Devon, the CRLFs come from the fact that the data source was a text editor. I imported the file as string and wanted to reshape it into a character matrix

Re: [Jprogramming] nube asks y?

2012-07-09 Thread Henry Rich
The problem with 2 : 'u@:v : (u v)' is that it repeats u and v . If you are try to build a big bivalent verb, u and v may themselves include 2 : 'u@:v : (u v)', and after a few levels of this repeated doubling you get very long verbs indeed. Henry Rich On 7/9/2012 11:00 AM, Andrew Nikitin

Re: [Jprogramming] Domain error for explicit conjunction

2012-07-07 Thread Henry Rich
You defined a conjunction that produces only a monadic valence. Try toy =: 2 : 0 : z =: u v '' x + y ) Henry Rich On 7/7/2012 2:38 PM, Max Harms wrote: toy =: 2 : 0 z =: u v '' x + y ) -- For information about J forums

Re: [Jprogramming] Domain error for explicit conjunction

2012-07-07 Thread Henry Rich
Here's a session log toy =: 2 : 0 : z =: u v '' x + y ) [ toy ] [ (2 : 0) ] : z=:u v'' x+y ) 5 [ toy ] 7 12 You gotta put in the colon : Henry Rich On 7/7/2012 3:18 PM, Max Harms wrote: Tried it. Didn't work. Same result. (Perhaps because I'm using 701?) - Max On Sat, Jul 7

Re: [Jprogramming] nube asks y?

2012-07-06 Thread Henry Rich
That's my 'bivalent': u^:(1:`(]v)) Henry Rich On 7/6/2012 7:13 PM, Don Guinn wrote: It's always bugged me that nl ignored x and y. So, for the fun of it, I thought I would try to make nl handle x and y. I pulled a lot of the code of nl into a tacit expression so x and y would be handled

Re: [Jprogramming] nube asks y?

2012-07-05 Thread Henry Rich
If you look at names you see list_z_@nl and if you look at nl there is a line nms=. (4!:1 y) -. ;: 'x y x. y.' So names doesn't report the names x and y. Seems reasonable. Henry Rich On 7/5/2012 4:20 PM, ed bierly wrote: NB. http://www.jsoftware.com/docs/help701/learning/24.htm (0

Re: [Jprogramming] Point in tetrahedron

2012-07-04 Thread Henry Rich
I think your theorem is true. Same idea for in_tetrahedra, but using determinants to check sign: int=:4 :'(-: 1|.)@(0!.0 *_1 1 _1 1)@(1((-/ .*)\.))2 ({ -1x)/ y' Use intolerant comparison for sign checks to help make unique assignment to cells on boundaries. Henry Rich On 7/3/2012 10:02

Re: [Jprogramming] $ interpolation

2012-07-02 Thread Henry Rich
Regex version: dolsub =: '\$[A-Z]*'(.@}. rxapply) This just uses the current locale. Henry Rich On 7/2/2012 11:52 AM, Raul Miller wrote: Some programming languages (unix shell, perl, php) provide a $ substitution mechanism where a literal string may contain embedded variable references

Re: [Jprogramming] 'for.' control command

2012-06-29 Thread Henry Rich
To run a verb, you have to give it an operand, even if it doesn't use one. Try print '' Henry Rich On 6/29/2012 2:43 AM, Charles Pechacek wrote: Hello I have been trying to get a handle on the 'for.' control command, using a little program taken from a Pascal book, of which I have

Re: [Jprogramming] 'for.' control command

2012-06-29 Thread Henry Rich
I mean humbug '' Henry Rich On 6/29/2012 2:43 AM, Charles Pechacek wrote: Hello I have been trying to get a handle on the 'for.' control command, using a little program taken from a Pascal book, of which I have written a script as follows: load 'print' humbug=: 3 : 0 for. : i.3 do

Re: [Jprogramming] permutation list

2012-06-26 Thread Henry Rich
Go to http://www.jsoftware.com/jwiki/Essays/Combinations and use R. E. Boss's version, which appears just above the pretty pictures. This gives combinations, not permutations, but there are 210 of them. Henry Rich On 6/26/2012 12:14 PM, ed bierly wrote: what is the best way to get

Re: [Jprogramming] permutation list

2012-06-26 Thread Henry Rich
Take the time to ponder R. E. Boss's version (in the Wiki). It is beautiful, and I have tried without success to make any improvement. $ 12 comb 24 2704156 12 In about 1 second. Henry Rich On 6/26/2012 8:54 PM, Linda Alvord wrote: I wrote a book called Probability in APL many years ago

Re: [Jprogramming] eigenvalues

2012-06-12 Thread Henry Rich
On 6/11/2012 9:34 PM, Raul Miller wrote: -/ .* performs only one multiply. Keep in mind that -/ .* is nothing like DET. It uses rules of linear algebra to calculate a result in far less than O(!n) time. Henry Rich

Re: [Jprogramming] eigenvalues

2012-06-12 Thread Henry Rich
, rather than requiring a new DET? Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] eigenvalues

2012-06-12 Thread Henry Rich
to 4x4 matrices it won't get out of hand. LAPACK is 3x faster for 4x4s, on my machine, 1e7x faster for 12x12. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] eigenvalues

2012-06-12 Thread Henry Rich
will send you what I have if you like. The main point is, doing many eigenvalue calculations in parallel may be a winner. Henry Rich On 6/12/2012 11:08 AM, Raul Miller wrote: On Tue, Jun 12, 2012 at 10:41 AM, Henry Richhenryhr...@nc.rr.com wrote: That may be. But no way do you do a determinant

Re: [Jprogramming] eigenvalues

2012-06-11 Thread Henry Rich
matrix ev =: 1 {:: p.@cpoly This is going to run in time O(!n), in other words, small matrices only. (It's barely faster than the boxed version and takes a little less space, but neither version takes much space) Henry Rich On 6/10/2012 11:26 PM, Marshall Lochbaum wrote: It looks like

Re: [Jprogramming] take

2012-06-01 Thread Henry Rich
Oh, that's the asymmetry of ; again! You'd have to use (0;1;a:) { i. 2 2 3 Henry Rich On 6/1/2012 2:38 AM, Steven Taylor wrote: Thanks bob. That makes sense now. (0;1;1) { i. 2 2 3 2 (0;1;1) { i. 2 2 3 3 5 (0;1;(0 2)) { i. 2 2 3 3 4 5 (0;1;(0 2)) { i. 2 2 3 3 5

Re: [Jprogramming] 'a b c' =. 1;2;3 unboxes?

2012-05-31 Thread Henry Rich
I don't know that it has an official name. I called it multiple assignment in JfC. We have also the multiple AR assignment '`plus minus' =. +`- and the indirect assignment names =. ;: 'one two' (names) =. 1 2 Henry Rich On 5/31/2012 12:24 PM, Steven Taylor wrote: Hi, just looking

Re: [Jprogramming] how to work with images - or 2D arrays?

2012-05-30 Thread Henry Rich
Be it noted that u;.3 and u;._3, which are useful for filtering, should be applied at rank 2 or lower, to avoid the construction of an expensive intermediate table. Henry Rich On 5/30/2012 5:40 PM, Devon McCormick wrote: Hi - this is much clearer but I'm still not quite sure about

Re: [Jprogramming] boxed + indexing

2012-05-24 Thread Henry Rich
Yes, by design. It's so 1;2;3;4 produces what you want. There you don't need to box the last element explicitly. Alternatives are (, ) and , . ; is midway between those. Henry Rich On 5/24/2012 1:48 AM, Steven Taylor wrote: it's always puzzled me why it is necessary to box the last item

Re: [Jprogramming] Memory corruption in J6.02

2012-04-25 Thread Henry Rich
I have tracked this down to numeric dyad E. which seems to cause wild stores to memory, sometimes wiping out data, sometimes scripts. In our new open-source environment, how do bugs get fixed and released? Henry Rich On 4/24/2012 9:52 PM, Henry Rich wrote: Working on R. E.'s latest problem, I

Re: [Jprogramming] Memory corruption in J6.02

2012-04-25 Thread Henry Rich
. this is the culprit -- y E. z y ) jtree =: ([: ~.@; joinroutes)/ If I uncomment the indicated line, I get a loop. That implicates numeric dyad E. . Henry Rich On 4/25/2012 9:54 PM, Joey K Tuttle wrote: Henry, I get different errors from different versions of j (e.g. 32 vs 64 bit J7

Re: [Jprogramming] all paths in a graph

2012-04-24 Thread Henry Rich
Can the graph contain a cycle? If so, what should be done? Henry Rich On 4/24/2012 11:47 AM, R.E. Boss wrote: I would like to know other solutions. And perhaps learn why it took me so long. R.E. Boss -Oorspronkelijk bericht- Van: programming-boun...@jsoftware.com

[Jprogramming] Memory corruption in J6.02

2012-04-24 Thread Henry Rich
Working on R. E.'s latest problem, I hit an interpreter bug. The session log is load 'C:\JPrograms\temp\interpbug.ijs' jtree G |domain error: jtree | jtree G X 10 12 Y 12 15 (10 12) joinroutes (12 15) ┌──┐ │┌┐│ ││10 12 15││ │└┘│ └──┘

Re: [Jprogramming] index of matched items

2012-04-23 Thread Henry Rich
Source =. 'a';'bcd';'e';'g' Target =. 'e';'a';'bcd';'f' getIndex =: i.~ NB. not e. shouldReturn =. 1 2 0 4 NB. 'not found' for i. is #x assert (Source getIndex Target)-:shouldReturn NB. -: not = Henry Rich On 4/23/2012 7:13 AM, Joe Bohart wrote: Hi J'ers, I'm trying

Re: [Jprogramming] index of matched items

2012-04-23 Thread Henry Rich
That convenience would also obtain (in J) if the 'not found' result were _1; and then the 'not found' entry would be known in advance and we wouldn't have to calculate it. Henry Rich On 4/23/2012 5:28 PM, Devon McCormick wrote: The convenience of index returning one more than the maximum

Re: [Jprogramming] Problem with Append in an Adverb

2012-04-11 Thread Henry Rich
No error; the modifier is ALWAYS evaluated before its x and y operands: see http://www.jsoftware.com/help/jforc/verb-definition_revisited.htm#_Toc191734405 http://www.jsoftware.com/help/jforc/writing_your_own_modifiers.htm#_Toc191734495 Henry Rich On 4/10/2012 11:48 PM, Paul Jackson wrote

Re: [Jprogramming] one element list of an integer to an atom

2012-03-29 Thread Henry Rich
Or better, '' ($ ,) data (special code) Henry Rich On 3/29/2012 6:46 AM, Simon Barker wrote: The old APL idiom was '' {reshape} data which translates as '' $ , data In J. -Original Message- From: programming-boun...@jsoftware.com [mailto:programming-boun

Re: [Jprogramming] Problem working with data loaded from a file

2012-03-29 Thread Henry Rich
Just use =:(,L:0) instead of = and it will do what you want. stringequal =: =:(,L:0) Henry Rich On 3/29/2012 8:59 PM, PackRat wrote: Devon McCormick wrote: So is this an accurate, if simplified, representation of what you want to do? str0=. ,.'A';'B';'NG';'Yow

Re: [Jprogramming] Problem working with data loaded from a file

2012-03-29 Thread Henry Rich
I should add, you still can't use select. unless you do what I suggested earlier. Henry Rich On 3/29/2012 8:59 PM, PackRat wrote: Devon McCormick wrote: So is this an accurate, if simplified, representation of what you want to do? str0=. ,.'A';'B';'NG';'Yow' col2search

Re: [Jprogramming] Extracting digits of Pi

2012-03-25 Thread Henry Rich
Oops, for some reason I thought you wanted even and odd digits. To get first and last, you can use a=.10 #.^:_1 .@o.10x^199 'first last' =. (.-:#a) ({. ; }.) a first 3 1 4 1 5 ... last 9 8 2 1 4 ... On 3/25/2012 10:29 AM, Henry Rich wrote: a=..@o.10x^199 'evendig

Re: [Jprogramming] Challenge 8 A Shamrock for St. Patrick

2012-03-21 Thread Henry Rich
Cute! J version: 'radar' plot 0 2p1;'1 + (cos 3*y) + *: sin 3*y' Henry Rich On 3/21/2012 5:55 AM, Boyko Bantchev wrote: FWIW, the cleanest mathematical / programmable trefoil that I know of is the following (I am too lazy to do it in J, so Gnuplot): set size ratio 1.08 set parametric set

Re: [Jprogramming] why=: 13 :'y*y*y'

2012-03-19 Thread Henry Rich
Agreed. Henry Rich On 3/19/2012 9:05 AM, Dan Bron wrote: Though not my usual position on J development, I'd support decommissioning 13 : . I see its function as more appropriate to a standard library than a primitive. For one thing, libraries are easier to change than primitives

[Jprogramming] stack error using m} causes crash

2012-03-17 Thread Henry Rich
u =. 1 { u u 5 stack error u =. 1 (0}) u crash J602. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] 13 :

2012-03-17 Thread Henry Rich
There's nothing wrong with the explicit form, except the verbosity. And, in this case, the tacit form is 100 times faster (that's unusual). Henry Rich On 3/17/2012 8:45 PM, David Ward Lambert wrote: In this experiment the tacit expression runs faster in less space than the explicit verb

Re: [Jprogramming] Socket problem in 6.02

2012-03-03 Thread Henry Rich
Yeah, I can do that (in fact, that was the first thing I did, to cover up the problem). I was hoping to fix the problem, but if the code is ugly and not going to change, I'll just assume the error is in the message handling in j.exe. Henry Rich On 3/3/2012 7:04 PM, bill lam wrote: I

Re: [Jprogramming] Challenge 6 Many Many Cherry Trees

2012-02-28 Thread Henry Rich
The rank of (:@?) is 0; the rank of ([::?) is _ . So g creates fill BEFORE :, f does it AFTER :. g1=: 13 :'([::?)0~:i.# y' g1 'abcde' 1 0 0 0 0 2 1 0 0 0 3 2 1 0 0 4 1 3 2 0 3 1 4 2 5 Henry Rich On 2/28/2012 7:57 PM, Linda Alvord wrote: Henry, I have hit a snag in how

Re: [Jprogramming] Challenge 6 Many Many Cherry Trees

2012-02-27 Thread Henry Rich
@ has its uses. tree =. (] ; ;/@,.)' ' ;@({~ |.)1 :@?~@:@i.@# tree 'abcde' a b a b a c b c a d d b a e c Henry Rich On 2/27/2012 9:31 PM, Kip Murray wrote: Here is how I would now do it, borrowing sh and the idea of using |. from you, Linda. sh

Re: [Jprogramming] Sequential Machine

2012-02-25 Thread Henry Rich
Thanks. Your problem is the old 'x ; boxed y' error. (0;sj;mj2) ;: y +---+--+-+--+---+-+-+-+-+-+---+-+---+-+ |sum|=.|(|i.|3 4|)|+|/|.|*|0j4|+|pru|4| +---+--+-+--+---+-+-+-+-+-+---+-+---+-+ Henry Rich On 2/24/2012 11:58 PM, Don Guinn wrote: d332 for ;: in J Vocabulary. I didn't want

Re: [Jprogramming] Sequential Machine

2012-02-24 Thread Henry Rich
Where is this help, where sj and mj are defined? Henry Rich On 2/24/2012 7:25 PM, Don Guinn wrote: I've lost track of the number of times I have tried to make dyadic ;: work. I read it, understand it (I think), but I can't get it to work. The general description has m, the input mapping

Re: [Jprogramming] Control error when loading script into ijx window (J602)

2012-02-21 Thread Henry Rich
I use wd 'wait' as a lightweight way to get something like a password. Henry Rich On 2/21/2012 5:17 AM, bill lam wrote: I guess these are really ancient codes. the wd'wait' is rarely used in modern J base libary or addons code, and the gtkwd does not support it. And wd'q' will raise domain

Re: [Jprogramming] Gerunds (was Re: Verb display in function tables)

2012-02-20 Thread Henry Rich
|+--+--+|| || ||+-+---+|* ||$:|:||| || |||/|+-+|| |+--+--+|| || ||| ||+||| |||+-+---+| || ||| |+-+|| ||| | || ||+-+---+| ||| | || |+---+-+|| | |+--+---+| | ++---+ Henry Rich On 2/20/2012 9:39 AM, Don Guinn wrote: Perhaps I was just being a little picky in the distinction. But the distinction between adverbs and conjunctions is important. It is similar to the distinction

Re: [Jprogramming] serialization, in J

2012-02-19 Thread Henry Rich
If you use 0!:100 rather than . you can do it more easily: 0!:100 'copyoflist=.', 5!:5'list_z_' copyoflist 3 : 0 w=.{.wcsize'' ... ) 0!:100 is multi-line . with only side-effects, no return value. Henry Rich On 2/18/2012 3:10 PM, Raul Miller wrote: In another thread, I was struggling

Re: [Jprogramming] Verb display in function tables

2012-02-18 Thread Henry Rich
I think Dan has it right. A gerund is an atomic representation of a verb. Could be a scalar (I use them that way a lot). Henry Rich On 2/18/2012 1:10 PM, Dan Bron wrote: I'm not sure gerunds are defined anywhere. But if they were, the phrasing might be arrays of atomic representations

Re: [Jprogramming] Verb display in function tables

2012-02-18 Thread Henry Rich
I personally use 'gerund' to mean 'array (or atom) of atomic representations of verbs' and 'atomic representation' (or 'AR') to mean 'a scalar box containing a description of an entity'. I think this matches the usage of Ye Dic. Henry Rich On 2/18/2012 2:37 PM, Dan Bron wrote: Raul wrote

Re: [Jprogramming] quote problem

2012-02-12 Thread Henry Rich
not, properly double quotes? Henry Rich On 2/12/2012 9:40 AM, R.E. Boss wrote: The (input) string should be considered as one group (of chars). Quoting is needed if the first or the last (or both) is not a quote, all inside quotes should be doubled if they are not. R.E. Boss

Re: [Jprogramming] quote problem

2012-02-11 Thread Henry Rich
Questions: 0. Even if we can detect an ill-formed string, what do you mean, 'repair' it? 1. In what context is the string to be valid? In particular, are control words allowed? 2. Is the string '2!:55 $0' a valid string? What about 'each_z_=:$0'? Henry Rich On 2/11/2012 1:04 PM, R.E

Re: [Jprogramming] Another early morning exercise

2012-02-05 Thread Henry Rich
They shouldn't agree, and they are both correct. u@:v y is u v y ([: u v) y is u v y u@v y is u@:vv y which differs in rank: |:@:*:*: is not the same as |:@:: Henry Rich On 2/5/2012 11:00 PM, Linda Alvord wrote: Shouldn't these agree? (|: @ *:)i. 2 2 0 1 4 9

Re: [Jprogramming] Eigen or Eigan?

2012-02-04 Thread Henry Rich
Agreed, and note that solving the characteristic polynomial is NOT used for finding eigenvalues of any but the smallest systems. *Numerical Recipes*, which generally thinks that any citizen can write their own code to do almost anything, suggests that you leave eigenvalues to LAPACK. Henry

Re: [Jprogramming] Challenge 5 Super Bowl Supposition

2012-01-31 Thread Henry Rich
There has to be some a priori knowledge of the two teams' strengths. Henry Rich On 1/31/2012 4:46 AM, Linda Alvord wrote: Challenge 5 Super Bowl Supposition PLEASE DO NOT RESPOND UNTIL 2/6/2012 12 am EST As the Super Bowl approaches, suppose it will be decided like baseball. Four

[Jprogramming] OpenSSL library?

2012-01-21 Thread Henry Rich
Does anyone have a J suite that sends messages using DLL calls to the OpenSSL library? Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] i.!.1e_7~

2012-01-17 Thread Henry Rich
,: ]) 0 3 0.3 3.2 0.6 2 2.3 2.6 3 0 7 2 7 2 7 7 7 7 0 3 0.3 3.2 0.6 2 2.3 2.6 3 Henry Rich On 1/16/2012 2:37 PM, Roger Hui wrote: You can use : as part of the hashing function and yes you do have to hash x*1-t and x%1-t . On Mon, Jan 16, 2012 at 11:19 AM, Raul Millerrauldmil

Re: [Jprogramming] i.!.1e_7~

2012-01-17 Thread Henry Rich
Yeah, I was solving the wrong problem. Never mind. Henry Rich On 1/17/2012 12:19 PM, Roger Hui wrote: In 0.2 tidr x=:0 3 0.3 3.2 0.6 2 2.3 2.6 3, an index of 8 as the index of 3 seems an usual result. On Tue, Jan 17, 2012 at 4:49 AM, Henry Richhenryhr...@nc.rr.com wrote: Does this work

Re: [Jprogramming] i.!.1e_7~

2012-01-16 Thread Henry Rich
You can sort the lists and then compare adjacent values; find superfluous ones; then i.!.0 to find them in the original list. A tricky part is that proximity is not a transitive property. If the tolerance is 2, and the data is 1 2 3 4 5 6 7 what should the result of the i.~ be? Henry Rich

Re: [Jprogramming] FW: jsoftware bridge deal challenge

2012-01-10 Thread Henry Rich
- t . Sum to get total for the hand. Henry Rich On 1/9/2012 11:33 PM, Nick Simicich wrote: Many years ago, I wrote a constrained bridge hand generator. This is the problem: Bridge is an interesting game. You play and you learn clues about the other hands. These clues become constraints

Re: [Jprogramming] Boxes of different lengths

2012-01-10 Thread Henry Rich
Another way, not better: (~.@{. ]`[`(a: #~ :@{:@[)} /./) DATA Henry Rich On 1/10/2012 11:30 AM, Devon McCormick wrote: Beginner questions are welcomed. Here's one way to include empty boxes for keys without any values: ] DATA=: 0 0 1 1 1 1 2 2 2 2 2 4 4 4 5 5,: 5 0 7 8 9 2 2 5 5 5 3

Re: [Jprogramming] Intro to under

2012-01-06 Thread Henry Rich
To be precise, f.:g y [image: $\leftrightarrow$] gi f g y x f.:g y [image: $\leftrightarrow$] gi (g x) f (g y) and f.g [image: $\leftrightarrow$] f.:gmg where mg is the monadic rank of g. I would change the Wiki page if it didn't seem heretical to correct Roger. Henry Rich On 1/6/2012 6:21

Re: [Jprogramming] timer in j701?

2012-01-05 Thread Henry Rich
I'm still on 602 but if I ever moved to J7 I would certainly need the timer to work, with the blocking problem fixed. Henry Rich On 1/5/2012 3:17 PM, Eric Iverson wrote: Just realized wd'timer' keeps firing and if that is what you want then you might be able to ignore the block and simply get

Re: [Jprogramming] Asking Are you still alive?

2012-01-02 Thread Henry Rich
that the machines be on the same local network or machine. Sockets are completely general. Henry Rich On 1/2/2012 2:38 PM, Ian Clark wrote: Thanks, Raul. I'll look again at the sockets solution. Some time since I ran that lab, but I seem to recall it had a timer to poll the link hidden

Re: [Jprogramming] Debian Forum comparing J to Brainf*

2011-12-25 Thread Henry Rich
Well, Java doesn't use the Iverson bracket, so if they say return x 20; it means something different (it returns a boolean). That's a different battle to fight. Henry Rich On 12/25/2011 10:42 PM, Marshall Lochbaum wrote: Actually I think the Java (which was in fact Java rather than C

Re: [Jprogramming] choosing between alternates (iif, ifelse)

2011-12-22 Thread Henry Rich
be turned into a single compound verb. In addition to avoiding the ,: there is the greater payoff of performing in-place operation when you have the form name =: q} a,:name Similar arguments apply. The given variant is in-place, while the equivalent name =: a q}@:,: name is not. Henry Rich

Re: [Jprogramming] choosing between alternates (iif, ifelse)

2011-12-21 Thread Henry Rich
the Special Code page. Henry Rich On 12/21/2011 11:43 AM, Marshall Lochbaum wrote: A more obvious way is to use (c { b,.a) . The key is to realize that saying (if c then a else b) is just selection: if c is 0, we pick b, and if c is 1, we pick a. So we rephrase as (c { b,a), and J's implicit rank

[Jprogramming] J Midterm exam 2011

2011-12-17 Thread Henry Rich
will note my use of the dice/toss thread. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] J Midterm exam 2011

2011-12-17 Thread Henry Rich
of a different distribution etc. But I never expected so many to do so well. Henry Rich On 12/17/2011 5:52 PM, Björn Helgason wrote: It is interesting to know how long you had been teaching them. These assignments were not that easy to solve. 2011/12/17 Henry Richhenryhr...@nc.rr.com Kids

Re: [Jprogramming] J Midterm exam 2011

2011-12-17 Thread Henry Rich
choose it. The name of the course is Programming For Scientists And Engineers, and in the description I bill the course as programming for people who need to write their own code that they will use for their own projects, rather than code that other people will run. Henry Rich On 12/17/2011 10:17

Re: [Jprogramming] How #: should have been designed

2011-12-12 Thread Henry Rich
different. Here, I disagree. There need to be two variants, one treating the bits as signed, one as unsigned. Since that seems inconvenient, we need to pick one variant, and the unsigned one seems clearly more useful. Henry Rich On 12/12/2011 9:31 AM, Raul Miller wrote: Ok... This, combined

Re: [Jprogramming] How #: should have been designed

2011-12-12 Thread Henry Rich
I like your leading-digit-negative idea better too. Rather than prepending a leading _1, you could just change the high-order 1 to _1 . Henry Rich On 12/12/2011 5:57 PM, Marshall Lochbaum wrote: Those are some very good arguments. Personally, I think my version is mathematically more well

Re: [Jprogramming] How #: should have been designed

2011-12-12 Thread Henry Rich
is anomalous. And you can do |@:#: if you don't like the negative sign bit. Still differs from 2#:, though. Henry Rich On 12/12/2011 7:44 PM, Marshall Lochbaum wrote: You can't, unfortunately. _10, for example, is #._1 0 1 1 0 , which is the shortest possible representation for it. In fact, my code only

Re: [Jprogramming] How #: should have been designed

2011-12-12 Thread Henry Rich
? What 'uniqueness' do you mean? With only the MSB made negative, there is a unique representation of any value in n bits. It is true that _3 is _1 0 1 _1 1 0 1 _1 1 1 0 1 etc, depending on the length of the representation. Henry Rich On 12/12/2011 8:44 PM, Marshall Lochbaum wrote: So

Re: [Jprogramming] How #: should have been designed

2011-12-10 Thread Henry Rich
Maybe not an improvement, but this is how I would have done back in my hardware-design days: hcinv =. -~/@:#.@:(~:/\)@:((,1),:)1 Quite a bit more elegant in wires than in J! Henry Rich On 12/10/2011 1:01 AM, Kip Murray wrote: Now we need an inverse for Raul's improved #: (hash colon

Re: [Jprogramming] How #: should have been designed

2011-12-10 Thread Henry Rich
Same idea, better implementation hcinv =. -/@:#.@:(,: +:@(1{.))1 Henry Rich On 12/10/2011 10:48 AM, Henry Rich wrote: Maybe not an improvement, but this is how I would have done back in my hardware-design days: hcinv =. -~/@:#.@:(~:/\)@:((,1),:)1 Quite a bit more elegant in wires than

Re: [Jprogramming] How #: should have been designed

2011-12-10 Thread Henry Rich
-save adder, and the building blocks to use for it. You could emulate any or all of that, but I'm not sure it's interesting to do so. Henry Rich On 12/10/2011 7:48 PM, Kip Murray wrote: Cool. I think it is an improvement because it neatly avoids a case statement. Now I wonder if we could

Re: [Jprogramming] How #: should have been designed

2011-12-10 Thread Henry Rich
very useful (though the MH instruction in S\360 worked that way). nxn-2n is more useful. Henry Rich On 12/10/2011 9:25 PM, Kip Murray wrote: What do you recommend for the high-order bit? I am off my reservation here. Thought there might be a clever way to add positive numbers using / so

Re: [Jprogramming] How #: should have been designed

2011-12-10 Thread Henry Rich
of machines that used other forms of number-representation. Henry Rich On 12/10/2011 10:02 PM, Kip Murray wrote: Let us add 1 1 0 and 0 1 0 in a simple-minded way working from right to left, and writing carries above the addition: 1 1 0-- these are carries 1 1 0 0 1 0

Re: [Jprogramming] Turkey Roll - Challenge 2

2011-12-06 Thread Henry Rich
didn't see that trick in the special code. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Turkey Roll - Challenge 2

2011-12-05 Thread Henry Rich
If you are OK with @: , then we agree. @ is hard for beginners. u@v is equivalent to u@:vv or ([: u v)v u@v@w is u@:vv@:ww or ([: ([: u v)v w)w Let us use [: u vor u@:v as we like, and specify a rank when we need one. Henry Rich On 12/5/2011 9:57 PM, Linda Alvord wrote

Re: [Jprogramming] Turkey Roll - Challenge 2 Rich Text

2011-12-01 Thread Henry Rich
| +---+---+---+---+---+---+---+---+---+---+ |o o|o |o o|o |o |o o|o |o o| |o o| |o o| o |o o| o | |o o| |o o| o |o o| |o o| o|o o| o| o|o o| o|o o| |o o| +---+---+---+---+---+---+---+---+---+---+ Henry Rich, whose @ will be pried from his cold dead fingers On 12/1/2011 6:25 PM, Linda Alvord wrote: I was curious

Re: [Jprogramming] Turkey Roll - Challenge 2 Rich Text

2011-12-01 Thread Henry Rich
. There is no way to write a single word that produces different results when you repeat it. toss''is as close as you get. Henry Rich On 12/1/2011 8:05 PM, Linda Alvord wrote: I pasted the line together so 'o' looked ok. It was where the line broke in my message. I tried it a couple

Re: [Jprogramming] J killing boo-boo

2011-11-28 Thread Henry Rich
the problem is just a quirk of 18!:4. Someday I'll learn the source enough to explain what's happening. Henry Rich On 11/28/2011 9:12 PM, bill lam wrote: invoke dyad cocurrent should already raise by segmentation fault. ''cocurrent'base' Втр, 29 Ноя 2011, Ian Clark писал(а): Yes, it doesn't

Re: [Jprogramming] FW: Copying a result

2011-11-26 Thread Henry Rich
' ┌─┬┬──┬─┐ │a│list│of│boxes│ └─┴┴──┴─┘ setboxforemail 1 ;: 'a list of boxes' +-++--+-+ |a|list|of|boxes| +-++--+-+ Then you have to hope the reader is using a fixed-width font. Henry Rich On 11/26/2011 4:56 AM, Linda Alvord wrote

Re: [Jprogramming] multiple boxing

2011-11-25 Thread Henry Rich
Or (`(@$:);.1~ ~:/\inv@:(={.)) but that's window dressing. This is a brilliant, beautiful solution that Dan found. Henry Rich On 11/25/2011 9:01 AM, Raul Miller wrote: Note that (]`(@$:);.1~ [: ~:/\inv {. = ]) 1 1 2 2 3 3 4 2 3 4 4 1 2 2 2 1 also works. On Fri, Nov 25, 2011 at 8:54

[Jprogramming] printf addon now available

2011-11-25 Thread Henry Rich
I have put printf in as an addon, as format/printf. This version supports the '0' flag (fixing a longstanding deficiency). I have downloaded it to my J602 system but I would appreciate it if someone verified that it works on J7. A test script is included. Henry Rich

Re: [Jprogramming] One noun with two names

2011-11-24 Thread Henry Rich
of ] . Henry Rich On 11/24/2011 1:44 AM, Roger Hui wrote: This does not apply for the first example, nor for the general case of the third example. Not sure about the second example. In any case you can get answers to these questions yourself by doing some experiments and checking

Re: [Jprogramming] One noun with two names

2011-11-24 Thread Henry Rich
Well... there is a section of JfC mentioning this stuff. But a Wiki page would be good, especially if Roger can explain what subtleties gave him pause. Henry Rich On 11/24/2011 2:30 PM, Marc Simpson wrote: On Thu, Nov 24, 2011 at 7:11 PM, Ric Sherlocktikk...@gmail.com wrote: That's great

Re: [Jprogramming] One noun with two names

2011-11-24 Thread Henry Rich
Of course, I see now, when you copy you have to update the reference counts in each atomic box. That explains the performance of a great many expressions that I couldn't understand before. Thanks. I'll be at the conference! Henry Rich On 11/24/2011 8:08 PM, Roger Hui wrote: The logic

Re: [Jprogramming] One noun with two names

2011-11-23 Thread Henry Rich
Also, there is an implicit y =. argument to begin every explicit verb, and it would be a pity if that required a copy of the data. Henry Rich On 11/23/2011 9:36 AM, Roger Hui wrote: Names are reference-counted so that if you say a=:b=: 123 the reference counts for a and b are each one more

Re: [Jprogramming] Power

2011-11-22 Thread Henry Rich
))\))^:(~:/@}.)^:_ (0,y,y) which would set p to the place where the cycle was detected, and v to the value detected. Then carry on as required. Henry Rich On 11/22/2011 6:16 AM, David Vaughan wrote: I see that the algorithm you suggested only works on linked lists. Is there a way to model linked lists

Re: [Jprogramming] primitives I want: shift

2011-11-17 Thread Henry Rich
So {.!.v would do what you want. Would also be nice if fill could be a non-atomic array. Henry Rich On 11/17/2011 3:52 PM, Raul Miller wrote: shift=: 4 :0 fill=. {.0#,y x |.!.fill y ) For example: 2 shift i.5 5

Re: [Jprogramming] primitives I want: shift

2011-11-17 Thread Henry Rich
Oh, I mistyped. I meant |.!.v where that would be defined as |.!.(v y) or |.!.(x v y) which would allow, for example, shift using the first element as fill. but if all you want is 0-fill, you have |.!.0 Henry Rich On 11/17/2011 4:41 PM, Raul Miller wrote: No. But shift

Re: [Jprogramming] Writing to files

2011-11-17 Thread Henry Rich
The noun must be a literal list, and the path to the file must exist. (The file itself need not exist) Henry Rich On 11/17/2011 8:09 PM, David Vaughan wrote: How do I write a noun to a file? I'm trying to use noun 1!:2'file' but I'm just getting rank and domain errors with all the things

Re: [Jprogramming] Boxing and Finding

2011-11-10 Thread Henry Rich
Nor does anything else, in general. Google the Halting Problem. My favorite version is http://ebiquity.umbc.edu/blogger/2008/01/19/how-dr-suess-would-prove-the-halting-problem-undecidable/ Henry Rich On 11/10/2011 8:54 PM, Marshall Lochbaum wrote: Look at the code and scratch your head. J

Re: [Jprogramming] Newbie question

2011-11-04 Thread Henry Rich
Just a quibble with terminology: 'item' means _1-cell. That concept does not apply here. If you define 'l-cell' to be the left rank of the verb, and 'r-cell' the right rank, you could say ...it loops through all the l-cells of x, then for each of those, all the r-cells of y... Henry Rich

Re: [Jprogramming] Newbie question

2011-11-04 Thread Henry Rich
I had the hardest time learning how dyad u/ works, but I was very proud to figure out ul rl _ . Now that I get u/, I use ul r/ instead. Henry Rich On 11/4/2011 10:28 AM, Roger Hui wrote: When table x f/y was introduced (at the very beginning) we did not fully comprehend the power of the rank

Re: [Jprogramming] Drop trailing zeros in a number

2011-11-04 Thread Henry Rich
Henry Rich On 11/4/2011 11:25 PM, Raul Miller wrote: |..:^:2: 123450245060x -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] J can't find the printf package

2011-11-01 Thread Henry Rich
OK, I want to port printf to J7.01 (there shouldn't be any changes). I see a Wiki page for Addons/Developers. But I can't find where the addons are in the path at Jsoftware. Is there a page that tells me what to do to publish my script after I have added the header? Henry Rich On 10/31

Re: [Jprogramming] J can't find the printf package

2011-11-01 Thread Henry Rich
I'll try to fix that long-standing deficiency when I port to 7.01. In the meantime, use %2.2d (it does support width, just not the 0 flag). Henry Rich On 11/1/2011 5:20 PM, Andrew Pennebaker wrote: I'd also like to see width specifiers in printf/sprintf, a la C. That would let printf do %02d

Re: [Jprogramming] J can't find the printf package

2011-11-01 Thread Henry Rich
OK, but suppose what you really wanted was This user has 05 credits left from a starting total of 097 Henry Rich On 11/1/2011 9:51 PM, Ric Sherlock wrote: I would've turned to: 'r02.0' (8!:0) 5 ┌──┐ │05│ └──┘ On Wed, Nov 2, 2011 at 2:35 PM, Raul Millerrauldmil...@gmail.com wrote

Re: [Jprogramming] Hexadecimal

2011-10-30 Thread Henry Rich
'0123456789ABCDEF' {~ 16 (#.^:_1) 456 1C8 x #: y converts y to base x, mod */x (with exceptions if x contains zeros). If you want to have an unlimited number of digits, use #.^:_1 as shown above. Henry Rich On 10/30/2011 8:50 AM, David Vaughan wrote: How could I convert decimal numbers

  1   2   3   4   5   6   7   8   >