Re: [Jprogramming] Sparse Arrays: What if the dense version is too big to exist?

2012-07-12 Thread Marshall Lochbaum
In the case of = (self-classify), we have the advantage that the indices are easily constructed. There is one 1 per column, located at (i.~ ~.) y. indices =. (,. i.@#) (i.~ ~.) 20 ?@$ 5 This finds these row indices, and appends the column indices, which are given simply by i. . sparse =. 1 (<

Re: [Jprogramming] eigenvalues

2012-06-10 Thread Marshall Lochbaum
It looks like the determinant conjunction . gives functions that are explicitly rank 2: -/ .* b. 0 2 _ _ This means we can't use a matrix of rank-1 polynomials as input without redefining the conjunction ourselves. Marshall On Sun, Jun 10, 2012 at 10:05 PM, Raul Miller wrote: > I am looking

Re: [Jprogramming] using mapped files

2012-05-08 Thread Marshall Lochbaum
Dyad (+/%#)\ is supported by special code (see http://jsoftware.com/help/release/infixavg.htm). However, testing shows that mean\ is not, so you'll want to use the expanded definition (or (mean\ f.), which also works). The special code allows me to run a moving average on 5e7?@$10 using only 0.5G

Re: [Jprogramming] Higher-rank modular exponent?

2012-05-03 Thread Marshall Lochbaum
Well, you can do this: (3 :'({.y)&|@^/ }.y')"1 ]10 14 22,.5 7 11,.400 4000 4 5 7 11 I don't think there's anything that uses rank reasonably. Marshall On Thu, May 3, 2012 at 3:32 PM, Joe Groff wrote: > Hi everyone. Verbs formed by (m&|@^) are implemented by modular > exponentiation: >

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-13 Thread Marshall Lochbaum
You're making a mistake in your treatment of functions. A function is not a formula. It is an association of a value in the codomain to each value in the domain, and if two functions have all of the same associations (which forces them to have the same domain), then they are identical. Therefore >:

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-11 Thread Marshall Lochbaum
In an attempt to clarify things, here are the collected axioms for a category: A category is a collection of objects and a collection of arrows. Each arrow has a source object and a destination object (which may be the same object). Each object has an identity arrow from itself to itself, which is

Re: [Jprogramming] Problem with Append in an Adverb

2012-04-06 Thread Marshall Lochbaum
The problem is that the adverb is being evaluated at (+ Arg), rather than waiting for a y argument. It appears that execution only waits if both u and y are present, and 'u' doesn't count because it is a string and not a variable. This looks like a bug to me. A simple fix is to place a trivial ment

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-03 Thread Marshall Lochbaum
9:06 AM, Raul Miller wrote: > On Mon, Apr 2, 2012 at 9:29 PM, Marshall Lochbaum > wrote: > > "The category of sets" means the category whose objects are sets and > whose > > arrows are functions. I suppose it's more precise to call it "the > category >

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-02 Thread Marshall Lochbaum
ment can't be the same as the identity for another, because they have different endpoints. Marshall On Mon, Apr 2, 2012 at 9:12 PM, Raul Miller wrote: > On Mon, Apr 2, 2012 at 6:30 PM, Marshall Lochbaum > wrote: > > A category is the collection of arrows AND objects. The object

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-02 Thread Marshall Lochbaum
consider three or so objects at a time, and a few maps between them, so we only have to shuffle category-theoretical axioms and not mess with set theory. Marshall On Mon, Apr 2, 2012 at 6:30 PM, Marshall Lochbaum wrote: > A category is the collection of arrows AND objects. The objects al

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-02 Thread Marshall Lochbaum
arrows act enough like functions to be useful. Marshall On Mon, Apr 2, 2012 at 5:30 PM, Raul Miller wrote: > On Mon, Apr 2, 2012 at 4:35 PM, Marshall Lochbaum > wrote: > > A category is a formal thing, which means that it is literally composed > of > > "objects" an

Re: [Jprogramming] Functors in mathematics, Haskell and an example in J

2012-04-02 Thread Marshall Lochbaum
A category is a formal thing, which means that it is literally composed of "objects" and "arrows," and that these names, and the entities themselves, mean nothing. We can think of a category as a set of objects, and for each ordered pair of (not necessarily distinct) objects a set of arrows from th

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

2012-03-30 Thread Marshall Lochbaum
Just to let everyone know, I've found the problem: in line 88 of pv.c, there's a line using swapc that should only use swap in some cases. This makes it so that 13 :'y+x' +~ but it's an improvement for the present. Marshall On Tue, Mar 20, 2012 at 9:12 AM, Raul Miller wrote: > On Tue, Mar 20

Re: [Jprogramming] J functors

2012-03-26 Thread Marshall Lochbaum
J in fact involves two types of functors: arrays as discussed, and functions. "Mapping" over functions is a bit harder to visualize, but it's helpful to think of a function as a value that depends on its input. In this case, when we apply a fork to two functions in order to refer to their values (o

Re: [Jprogramming] Word splitter

2012-03-24 Thread Marshall Lochbaum
No, it should be 1 0. Empty strings are allowed in the argument, as in '12,,4,5' . '' signifies a single empty string, just like 'a' signifies a single length-one string. The number of segments is equal to the number of commas, plus one, in all cases. Marshall On Sat, Mar 24, 2012 at 11:26 PM, Bl

Re: [Jprogramming] J701 : error with package manager

2012-03-13 Thread Marshall Lochbaum
You're using a double quote " instead of an empty string '' (it's easier to see in monospace). Marshall On Tue, Mar 13, 2012 at 3:56 PM, Devon McCormick wrote: > Since the last two ASCII values differ, I suspect you're not entering > the single quote twice at the end - or you could enter > 'u

Re: [Jprogramming] plot error

2012-03-01 Thread Marshall Lochbaum
for the new jconsole support and does not > apply to jgtk or jhs. Details like 32 vs 64 also nice to have. > > On Thu, Mar 1, 2012 at 3:45 PM, Devon McCormick > wrote: > > The 32-bit version still works under Windows 7. > > > > On Thu, Mar 1, 2012 at 3:27 PM, Marshall Lochba

Re: [Jprogramming] plot error

2012-03-01 Thread Marshall Lochbaum
Confirmed on Ubuntu. Oh no! Marshall On Thu, Mar 1, 2012 at 3:16 PM, William Szuch wrote: > Using Windows 7 > > > > load 'plot' > > plot i. 123 > > |assertion failure: cairo_glcmds > > | 0~:gtkcr,gtkpl > > > > Regards > > > > Bill Szuch > > > > > > > > ---

Re: [Jprogramming] Amend situation how-to?

2012-02-28 Thread Marshall Lochbaum
You'll want the more general form of indexing, using boxes. i.3 4 0 1 2 3 4 5 6 7 8 9 10 11 (<1 1) { i.3 4 5 _ (<1 1)} i.3 4 0 1 2 3 4 _ 6 7 8 9 10 11 A more complete description of selection is here: http://www.jsoftware.com/help/jforc/more_verbs_for_boxes.htm#_Toc191734399 Mar

Re: [Jprogramming] Verb display in function tables

2012-02-17 Thread Marshall Lochbaum
show =: 1 : '5!:5<''u''' should serve your purposes. Execute as an adverb, i.e. (+/%#) show +/ % # There are other formats, which you can find in the help section on foreigns under 5!: . Marshall On Fri, Feb 17, 2012 at 1:57 PM, Edward Mokurai Cherlin < moku...@sugarlabs.org> wrote: > I had

Re: [Jprogramming] wd emulation in jgtk

2012-02-12 Thread Marshall Lochbaum
; > pas 0 0; > > > ) > > > > > > run =: 3 :0 > > > wd TEST > > > wd 'pshow' > > > ) > > > > > > test_g_paint =: 3 :0 > > > size =. _2 {. ". wd 'qformx' > > > wd 'setxywhx g 0 0 ', ":size > > > glclear ''

Re: [Jprogramming] wd emulation in jgtk

2012-02-11 Thread Marshall Lochbaum
g_paint > again, try this. > > run =: 3 :0 > wd TEST > wd 'set edit *edit here' > wd 'pshow' > ) > > test_g_paint =: 3 :0 > glclear '' > glpixels 0 0 400 400,<.,(+/ 256&*) 256*400%~i.400 > ) > > if it does not di

Re: [Jprogramming] A new approach to J's rank and forks

2012-02-05 Thread Marshall Lochbaum
ng enough for use in the implicit mapping model I described. Marshall On Sun, Feb 5, 2012 at 4:07 PM, Boyko Bantchev wrote: > On 5 February 2012 20:04, Marshall Lochbaum wrote: > > ... > > I'm not sure what you mean about Haskell's "deriving" descriptor.

Re: [Jprogramming] A new approach to J's rank and forks

2012-02-05 Thread Marshall Lochbaum
askell description. My intention was to formalize the ideas in the paper, but since it's dynamically typed, the type signatures don't accomplish much. Marshall On Sun, Feb 5, 2012 at 12:37 PM, Boyko Bantchev wrote: > On 5 February 2012 06:28, Marshall Lochbaum wrote: > > I've w

Re: [Jprogramming] A new approach to J's rank and forks

2012-02-05 Thread Marshall Lochbaum
computations, and in this situation array theory will come in handy. Marshall On Sun, Feb 5, 2012 at 11:14 AM, William Tanksley, Jr wrote: > Marshall Lochbaum wrote: > > I've written a paper which describes a way to replicate and extend J's > > behavior with arrays

[Jprogramming] A new approach to J's rank and forks

2012-02-04 Thread Marshall Lochbaum
I've written a paper which describes a way to replicate and extend J's behavior with arrays and forks as part of a single framework. I thought this would be interesting to the J community since it elaborates on the kind of thinking that drives J's powerful approach to function application. https:/

Re: [Jprogramming] wd emulation in jgtk

2012-01-31 Thread Marshall Lochbaum
; GL2ExtGlcmds=: 0 > in base.cfg to force it use cairo backend before testing. > > gl2 rgb colors seemed swapped, and it needs a wd'pshow' before running any > gl2 commands. > > Also you may set the noun TileWM inside gtkwd to make a ptop a no-op so > that it > wil

Re: [Jprogramming] wd emulation in jgtk

2012-01-31 Thread Marshall Lochbaum
On further probing, it looks like the problem is in glpixels, which is causing all the windows to move slowly and sometimes hang. I'll see if I can boil that down to a simple script. Marshall On Tue, Jan 31, 2012 at 7:20 PM, bill lam wrote: > Втр, 31 Янв 2012, Marshall Lochbaum

Re: [Jprogramming] wd emulation in jgtk

2012-01-31 Thread Marshall Lochbaum
I'm running Linux 32 bit with gtk3. So far the big problem is that using wd commands immobilizes the jgtk window--I can type things in, but nothing happens when I press enter until I close the window. This is really hindering diagnostics. glqwh returns the size of the window as set by J, not the c

Re: [Jprogramming] Programming Digest, Vol 76, Issue 87

2012-01-26 Thread Marshall Lochbaum
Thanks for providing the link. The property that I had missed was "fractionality:" that (1 < (|@- <.)) . This would ensure that while doing the Euclidian algorithm, the magnitudes of numbers always decrease. However, this is not a necessary condition for the Euclidian algorithm to work. Another su

Re: [Jprogramming] Programming Digest, Vol 76, Issue 87

2012-01-24 Thread Marshall Lochbaum
gt; Scientific Services > > Office of Environment and Heritage > > Department of Premier and Cabinet > > PO Box A290 > > Sydney South > > NSW 1232 > > T: +61 2 99 955 490 > > E =: {~&:>`(i.&.:>)/ > > E'.@aeghimnorstuvw &g

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
6j0.6 0.6j0.6 Marshall On Sun, Jan 22, 2012 at 2:59 PM, Marshall Lochbaum wrote: > Well, there's a very simple fix for the problem we're seeing here. Here's > the definition of the remainder function, from vz.c (you don't have to read > the whole thing!) > > Z

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
bility issues, this is definitely a fix that needs to be made. Marshall On Sun, Jan 22, 2012 at 2:36 PM, Marshall Lochbaum wrote: > That isn't what complex | does, or what it should do, I think. However, it > is a consistent extension of "mod" to the complex numbers--we are

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
' of the real part and leave the imaginary part > untouched. >f=:(|9&o.)+j.&(11&o.)&] >7 f 73j73+i.6 > 3j73 4j73 5j73 6j73 0j73 1j73 > Perhaps this is not done by a complex '|' ? > > > > > > >

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
Well, I know complex floor was something Gene McDonnell was proud of, > and I expect it's embedded in some applications. You'll need to produce > a compelling argument for changing it. > > Henry Rich > > On 1/22/2012 12:38 PM, Marshall Lochbaum wrote: > > I'm

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
kes sense or that the current definitions are used in important code that would break under this remodeling. Marshall On Sun, Jan 22, 2012 at 12:49 PM, Don Guinn wrote: > The thing is that floor, ceiling, residue and antibase are related and all > should be handled by the same rules, whatever

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
Jan 22, 2012 at 12:08 PM, Henry Rich wrote: > As Don said, make sure you understand complex floor before you start > coding. > > Henry Rich > > On 1/22/2012 11:38 AM, Marshall Lochbaum wrote: > > The theory of moduli is based on the quotient group of the integers by a >

Re: [Jprogramming] 5|0 1 2 3 4 is not equal to 5|0 1 2 3 4 j.0

2012-01-22 Thread Marshall Lochbaum
The theory of moduli is based on the quotient group of the integers by a subgroup. For instance, the integers (mod 2) are produced by taking all the integers and identifying all the ones that are even, as well as all the ones that are odd. Then we get a two-element group which we can preform additi

Re: [Jprogramming] Advantages of J over Q (aka K4/Kdb+)

2012-01-17 Thread Marshall Lochbaum
The average below isn't tacit since it refers to the argument of the function, x. It's true that J's [ and ] do similar things, but with entirely different semantics: they are actually functions of one or two arguments that return the appropriate argument. Perhaps it's not so evident here, but in J

Re: [Jprogramming] 2!:1 doesn't do what I expect it to. Bug or feature?

2012-01-08 Thread Marshall Lochbaum
orum > archive if you are interested. > > Вск, 08 Янв 2012, Marshall Lochbaum писал(а): > > In J701, fork_jtask_[load'task' accomplishes this. fork is defined as > > fork_jtask_ =: [: 2!:1 '(' , ')&' ,~ ] > > > > However, in J602 it is ju

Re: [Jprogramming] 2!:1 doesn't do what I expect it to. Bug or feature?

2012-01-08 Thread Marshall Lochbaum
In J701, fork_jtask_[load'task' accomplishes this. fork is defined as fork_jtask_ =: [: 2!:1 '(' , ')&' ,~ ] However, in J602 it is just an alias for 2!:1, so it's best to assign as above in Unix if both J602 and J701 will be used. Marshall On Sun, Jan 8, 2012 at 10:46 PM, bill lam wrote: > It

Re: [Jprogramming] Getting the diagonal of a square matrix

2012-01-08 Thread Marshall Lochbaum
This never seemed intuitive to me either. I think it means that the indices are run together, i.e. in an ordinary table you have indices given by {@:(i.&.>)@:$ like ┌───┬───┬───┬───┐ │0 0│0 1│0 2│0 3│ ├───┼───┼───┼───┤ │1 0│1 1│1 2│1 3│ ├───┼───┼───┼───┤ │2 0│2 1│2 2│2 3│ └───┴───┴───┴───┘ And when

Re: [Jprogramming] Faster deb

2012-01-04 Thread Marshall Lochbaum
If you really want top-of-the-line performance, you'll have to go to a sequential machine. Here's my solution, which leaves the leading and trailing blanks in, then specifically deletes them. I don't claim that these tests are universal; it's quite plausible that a different mixture of blanks and w

Re: [Jprogramming] cyclical copy

2011-12-30 Thread Marshall Lochbaum
$ accomplishes this quite nicely. 4 $ 1 2 1 2 1 2 2 5 $ 1 2 1 2 1 2 1 2 1 2 1 2 Note, however, that $ always applies to the items of its right argument; behavior with a rank >1 right argument is confusing. Marshall On Fri, Dec 30, 2011 at 1:42 PM, Johann Hibschman wrote: > Continuing my

Re: [Jprogramming] Input from keyboard, output text to screen?

2011-12-30 Thread Marshall Lochbaum
Grouping of adjacent numbers is something that happens during word formation: it's embedded into the sequential machine ;: (the dictionary gives a rather opaque description of this). You should train yourself to do the same, so that you parse "1!:1 1" as ;: '1!:1 1' ┌─┬──┬───┐ │1│!:│1 1│ └─┴──┴─

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

2011-12-25 Thread Marshall Lochbaum
Actually I think the Java (which was in fact Java rather than C, although you had no way of knowing) was "if (x>20) return 1; else return 0;". My friend proposed this as a more readable version than ">&20" when I suggested it. In any case, I stand by my rhetoric; the actual code is irrelevant. Mar

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

2011-12-24 Thread Marshall Lochbaum
Well, I'm not tired of this stuff quite yet, so here goes: Brainfuck and APL/J/K get compared a lot on account of being "obfuscated." This is a bit unfair. The correct terms are, respectively, "contorted" and "terse." There is one thing that the two languages share: they are each an attempt to ge

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

2011-12-21 Thread Marshall Lochbaum
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 allows us to do (c { b,.a) for vector c, a, and b. That said, (c} b,:a) is faster,

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

2011-12-16 Thread Marshall Lochbaum
ation. Marshall On Fri, Dec 16, 2011 at 8:20 AM, Don Guinn wrote: > I don't understand what you mean by a right and left inverse to +/ . > > On Thu, Dec 15, 2011 at 7:52 AM, Marshall Lochbaum >wrote: > > > Yes, except there are an infinite number of choices. In that sense, it

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

2011-12-15 Thread Marshall Lochbaum
s impractical in actual problem solving. A similar > thing occurs with circular functions. > > 1 o.0.5+0,o.2 > 0.479426 0.479426 > > And that is why many proofs restrict functions to be single valued. > > On Wed, Dec 14, 2011 at 9:18 PM, Marshall Lochbaum >wrote: &

Re: [Jprogramming] A one-dimensional cellular automaton

2011-12-15 Thread Marshall Lochbaum
Rule 30 (i.e. replace (1 3 5 6 e.~) with ((8{.|.#:30) {~)) generally looks the best, because it's chaotic. Rule 110 (same, but with 110) is interesting because it's Turing complete. Marshall On Thu, Dec 15, 2011 at 7:00 AM, Zsbán Ambrus wrote: > The following code runs a one-dimensional cellula

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

2011-12-14 Thread Marshall Lochbaum
antibase2 has an inverse only for nonnegative numbers, given by #. twoscomplement's inverse is [:#. (* _1^0=i.@#)"1 signwithbits has inverse #. Marshall On Wed, Dec 14, 2011 at 11:10 PM, Kip Murray wrote: > Thank you, Raul. May we have inverses? > > On 12/14/2011 9:13 AM, Raul Miller wrote: >

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

2011-12-14 Thread Marshall Lochbaum
So, this will probably just look like a lot of math, but I think it's what you are trying to say: We can consider the vector space over the real numbers consisting of all infinite sequences of numbers with finitely many nonzero terms. So a member of this space can be expressed as a finite list tha

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

2011-12-13 Thread Marshall Lochbaum
Actually, I'm kind of surprised now that I didn't think of just reversing the order of #: . A binary number is computed as a stack, with the most significant digit being computed last but needed first to convert back to an integer. Hence it makes the most sense to put the least significant digit fi

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

2011-12-12 Thread Marshall Lochbaum
gt; _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 something like this: > > (-@(<&0) ,. #:) i:5 > > _1 0 1 1 > > _1 1 0 0 > > _1 1 0 1 > &g

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

2011-12-12 Thread Marshall Lochbaum
ith current code except for the > behavior of #: on negatives, which we agree 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: > &g

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

2011-12-12 Thread Marshall Lochbaum
I suppose my main objection to multiplying the entire base by a sign is that it makes it more complicated to assess whether a number can be derived from your version of antibase, and thus can be compared directly with another via -: . Specifically, your version requires that a number either consist

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

2011-12-12 Thread Marshall Lochbaum
Henry Rich wrote: > 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.

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

2011-12-12 Thread Marshall Lochbaum
d, [subtract] two tens, and [subtract] three units". > > Though this is subjective, it does allow one to reason about negative > > numbers in a straightforward and expected way: > > > > _123 + 456 > >333 > > _1 _2 _3 + 4 5 6 > >

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

2011-12-12 Thread Marshall Lochbaum
The problem with this is that we would prefer not to use negative numbers in antibase, since they can violate uniqueness of base representation. There's really no solution to this--my recommendation is to just never feed negative numbers to #: . However, an option that minimizes negative numbers (a

Re: [Jprogramming] Boxing and Finding

2011-11-10 Thread Marshall Lochbaum
On second thought, you could make a parser that applies the function to formal parameters x and y, and checks whether the results are the same, which should work for functions as simple as yours. Stay tuned--I might actually write this. Marshall 2011/11/10 Marshall Lochbaum > Look at the c

Re: [Jprogramming] Boxing and Finding

2011-11-10 Thread Marshall Lochbaum
Look at the code and scratch your head. J doesn't have that kind of power. Marshall 2011/11/10 Linda Alvord > a=: 0 : 0 > a is a > b is not a > c is a or not a > ) > a > a is a > b is not a > c is a or not a > > b=: <;._2 a > b > ---T--T---┐ > │a is a│b is not a│

Re: [Jprogramming] Finding & expanding files

2011-11-09 Thread Marshall Lochbaum
about > nouns, so that would be a few examples of general noun arguments. > > > > On Wed, Nov 9, 2011 at 7:06 PM, Marshall Lochbaum > wrote: > > That's what 1!:1 and 1!:2 are for. You should learn the first few of J's > > file foreigns; they are listed h

Re: [Jprogramming] Finding & expanding files

2011-11-09 Thread Marshall Lochbaum
shall. > > If I want to take a noun like 'all' which is just a list of text strings. > and save it as a standard text file 'all.txt' in a specific folder on my > system, how would you do that? > > Skip > > On Wed, Nov 9, 2011 at 8:34 PM, Marshall Lochbau

Re: [Jprogramming] Finding & expanding files

2011-11-09 Thread Marshall Lochbaum
(nl 0) lists all the nouns in boxed form, and 7!:5 gives the memory used by a noun in boxed form, so 7!:5 nl 0 gives you a nice list of all the memory being used. To save and recover a noun using a file, you can use the inverses (5!:5) and ". (". is a strict left inverse of 3 :'5!:5<''y''', at

Re: [Jprogramming] Finding & expanding files

2011-11-09 Thread Marshall Lochbaum
J provides a primitive for the unbox/ravel combo which doesn't introduce the fill. It's ; (raze, the semicolon). Marshall On Wed, Nov 9, 2011 at 7:46 PM, Ric Sherlock wrote: > I think this should show any log.gz file in c:\test4 or any sub-directory > of it: > dirtree 'c:\test4\log.gz' > > On

Re: [Jprogramming] Finding & expanding files

2011-11-09 Thread Marshall Lochbaum
I think actually shell&.> zipth <@,"1 lp is needed, since lp has rank 2. Or, if you're into less boxing and (slightly) less maintainable code, zipth <@shell@,"1 lp Marshall On Wed, Nov 9, 2011 at 6:08 PM, Ric Sherlock wrote: > you need: > shell &.> zipth&, &.> lp > > Just for clarity t

Re: [Jprogramming] Binary Addresses Method

2011-11-08 Thread Marshall Lochbaum
It's either a string file name on the left and a 2-dimension array of rgb values (ie. 256#.(red, green, blue)) one the right, or vice-versa. Do whichever one doesn't give you a domain error. Marshall On Tue, Nov 8, 2011 at 11:39 AM, David Vaughan wrote: > Thanks, I never realised all that stuff

Re: [Jprogramming] matrix multiplication (modeling in CUDA for a GPU)

2011-11-07 Thread Marshall Lochbaum
If we look at the block matrices, what we want is a matrix product on these, but with the operations of matrix addition and multiplication instead of the regular + and * . Thus, we can replace + and * in +/ .* with the corresponding +&.> and +/ .*&.> for boxed matrices, so mp =. +/ .* blockm

Re: [Jprogramming] joining strings

2011-11-04 Thread Marshall Lochbaum
Here's an example: xs =. 'a';'b';'c' join =: #@[ }. [:;,L:0 '' join xs abc ' ' join xs a b c Keep in mind that J strings are arrays of characters. There are no special functions for strings, because there's never a reason to restrict the domain of an array function to strings. Marshal

Re: [Jprogramming] Newbie question

2011-11-03 Thread Marshall Lochbaum
* has rank 0 already, so it isn't necessary. The definition of / is that it applies the verb with rank (left rank),_ . Essentially, this means that it loops through all the items of x, then for each of those, all the items of y, where an "item" is an item with the left rank of the verb. If you try

Re: [Jprogramming] Problem with "shape" ($)

2011-11-03 Thread Marshall Lochbaum
To clarify, your problem isn't part of the execution of $ . It occurs during the word formation step, which is when vectors are formed. J knows that numerics side-by-side form a list, so it will do that for you, but with names, it doesn't even now the part of speech, so it can't. Also note that acc

Re: [Jprogramming] Erase

2011-10-31 Thread Marshall Lochbaum
Erase will work on an unboxed list of words, as well as boxed words. If you give it a string, ;: will split it into words, and if you give it a box, ;: will fail and because of the ::] it will fall back on ] as a default, which does nothing before feeding the argument to 4!:55. Marshall On Mon, O

Re: [Jprogramming] Script - string operations

2011-10-28 Thread Marshall Lochbaum
It's naturally grouped from left to right, so what you have is ]`(a.{~32&+@:(a.&i.)) @. (>&64 *. <&91) @: (a.&i.) 'A' which first converts 'A' to a number, then applies all of the rest on the number. Thus (a.&i.) (numeric) gives #a. , giving you your index error after adding 32 and selecting

Re: [Jprogramming] problem with under

2011-10-26 Thread Marshall Lochbaum
You can use &.: and simply make the verb rank 0 (which is the rank of >), and then expand that to an expression using @: . However, &.> is an idiom that is really useful (it's the analogue of "_1 for arrays of boxes), so your code will be shorter and clearer if you learn to use it. I =: ([:/:":) &

Re: [Jprogramming] The word for arrays of rank > 2

2011-10-23 Thread Marshall Lochbaum
I don't think anything will keep me from calling it an "array with rank greater than 2." Marshall On Sun, Oct 23, 2011 at 10:10 PM, Henry Rich wrote: > 'cube' was suggested. Raul objected that a cube should have all axes of > equal length. > > 'cuboid' has been used in Ye Dic (in the descripti

Re: [Jprogramming] slice and dice operators

2011-10-21 Thread Marshall Lochbaum
I would describe one as compositions and the other as array combinators (or array operators). In a Factor-like notation, the first (and also forks) would be dataflow combinators, although that applies just as easily to the second. The distinction between these two fits into a larger distinction bet

Re: [Jprogramming] {. y produces an array.

2011-10-20 Thread Marshall Lochbaum
While that is an important property, your argument is a lot like saying that an empty list cannot be counted as a list because all other lists have a first element. Admittedly, scalars are very different from other arrays, but it's essential that we still be able to consider them as arrays because

Re: [Jprogramming] {. y produces an array.

2011-10-20 Thread Marshall Lochbaum
A more general solution is {.^:(#@$) , which will strip all the dimensions off the array. Marshall On Thu, Oct 20, 2011 at 7:34 AM, Raul Miller wrote: > {. gets the first item from an array. > > You might be wanting lim=. {.,y (which will always have lim be a rank 0 > array). > > But I do not

Re: [Jprogramming] Verb for computing a changeable expression

2011-10-19 Thread Marshall Lochbaum
.@googlemail.com> wrote: > Ignore the domain error thing that was just one of my usual careless > mistakes. > > But even so, the result is not right. > > (i.<.-:<:4) p 4 > 1r120 > (>:i.<.-:<:4) p 4 > 1r20 > > On 19 Oct 2011, at 17:03, Marshall

Re: [Jprogramming] Verb for computing a changeable expression

2011-10-19 Thread Marshall Lochbaum
bability of taking more b's than r's is the probability of > taking 3 b's = %24 plus the probability of taking 2 b's and 1 r = 24%~1+2+3 > which gives 7r24. Though I'm not actually sure my idea for the general case > is totally correct. > > On 19 Oct 2011, at 15

Re: [Jprogramming] Verb for computing a changeable expression

2011-10-19 Thread Marshall Lochbaum
The correct way is to compute all the terms in the expression and then multiply them together. Something like n* > *&.>/ >:@i.&.> n->:i.k However, the expressions you gave will return length errors, since (>:i.n-2) is patently not the same length as (>:i.n-1). What exactly are you trying to comp

Re: [Jprogramming] Operations on boolean lists

2011-10-13 Thread Marshall Lochbaum
You can just use rotate with rank: (|."0 1~ i.@#) 3 4#1 0 1 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 Also, if you wanted a solution using power, you could do 1&|.^:(<@#) 3 4#1 0 1 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 1 0

Re: [Jprogramming] lazily look for label?

2011-10-12 Thread Marshall Lochbaum
J's E. implements Boyer-Moore, which makes it much faster than a standard search. You could implement a standard search using sequential machines (well, if you don't mind a transition table that grows with the size of the label to find), but I'm fairly sure it's impossible to implement Boyer-Moore

Re: [Jprogramming] lazily look for label?

2011-10-12 Thread Marshall Lochbaum
In general, lazy lists and lazy-style programming are not well-supported in J. Even if you have a good representation of a lazy list, it won't work with J's array-processing style. The main reason J is so fast is that it performs each operation all at once, allowing for highly optimized operations

Re: [Jprogramming] Listing all a^b

2011-10-10 Thread Marshall Lochbaum
It just says that if each permutation (of axes) in P gives the identity on A, then any composition of those permutations also gives the identity. Marshall On Mon, Oct 10, 2011 at 4:49 PM, Brian Schott wrote: > I enjoyed the Essay and went on to view the embedded Essay here which > was fascinatin

Re: [Jprogramming] detecting name-clash in _z_

2011-10-09 Thread Marshall Lochbaum
A simple solution is just to keep all the exports in a separate file and look at that when you want to find the names you defined globally. I suppose you could also do a regex search for '_z_ *=[\.:]' . Marshall On Sun, Oct 9, 2011 at 1:28 PM, Ian Clark wrote: > It's not the top-level call that

Re: [Jprogramming] Agenda's rank error

2011-10-08 Thread Marshall Lochbaum
$i.10 is a 1-element list, while #i.10 is a scalar. You can determine this by looking at the shape: $ $i.10 1 $ #i.10 #@$ $i.10 1 #@$ #i.10 0 A scalar is defined as having zero dimensions, that is, the shape is an empty list. One important thing to know is that $ always returns a lis

Re: [Jprogramming] Image resizing/downsampling algorithm

2011-10-06 Thread Marshall Lochbaum
anti-aliased, but resize_image from image3.ijs in the image3 > addon subsamples. > Best, Cliff > > On 10/3/2011 10:52 PM, Marshall Lochbaum wrote: > > Does anyone know of a good J implementation of anti-aliased rescaling for > > bitmaps? My first attempt has been sl

Re: [Jprogramming] Fractals, Visualization and J

2011-10-05 Thread Marshall Lochbaum
J couldn't find 'view_m.ijs', so you'll need to give it more information. load '~addons/media/image3/view_m.ijs' worked for me (on Unix; if you have Windows replace slashes with backslashes). If that doesn't work, find the file and paste in the full path. Marshall On Wed, Oct 5, 2011 at 11:42

Re: [Jprogramming] help for verbs

2011-10-05 Thread Marshall Lochbaum
I strongly recommend the section in J for C Programmers that deals with rank: http://www.jsoftware.com/help/jforc/loopless_code_i_verbs_have_r.htm#_Toc191734331 for the definitions of verbs, see J's vocabulary page (f1 from a J window). Marshall On Wed, Oct 5, 2011 at 8:29 PM, olivier SAINT-EVE

[Jprogramming] Image resizing/downsampling algorithm

2011-10-03 Thread Marshall Lochbaum
Does anyone know of a good J implementation of anti-aliased rescaling for bitmaps? My first attempt has been sloppy and really slow. The more important part of the algorithm is downsampling--to increase the size I'll probably just end up using nearest-neighbor. Marshall ---

Re: [Jprogramming] Listing combinations

2011-09-27 Thread Marshall Lochbaum
There's a distinction between the algorithm and the implementation: Using for. instead of rank is an implementation detail--it can slow you down, but the asymptotic time remains the same. It's quite possible that the performance of comb could be improved by using tacit code. The difference here i

Re: [Jprogramming] Bug/Inconsistency among namelist verbs from z locale

2011-09-26 Thread Marshall Lochbaum
Well, if you really need it, here's a tacit version that should work: nlmonad =: [: cutopen_z_`(4!:1)@.(1 4 8 e.~ 3!:0) ((0 1 2 3"_)^:(0=#)) nldyad =: (4 :0 nlmonad) nms=.y if. #t=. x -. ' ' do. 'n s'=. '~*' e. t t=. t -. '~*' b=. t&E. &> nms if. s do. b=. +./"1 b else. b=. {."1 b

Re: [Jprogramming] Bug/Inconsistency among namelist verbs from z locale

2011-09-26 Thread Marshall Lochbaum
Step 1 is a problem. You never want to define global variables x and y . In fact, if you inspect the code for nl, you will find the line nms=. (4!:1 y) -. ;: 'x y x. y.' which specifically removes instances of x and y, as well as x. and y. . That's because nl is an explicit verb, so x and y are ove

Re: [Jprogramming] Consecutive Numbers in List

2011-09-23 Thread Marshall Lochbaum
On Fri, Sep 23, 2011 at 10:36 PM, Roger Hui wrote: > Marshall, I am curious: which of the following > two statements do you think is better? > > Apply +/ on prefixes of suffixes > +/ on prefixes of suffixes > > p.s. I showed your solution at the Minnowbrook > conference here

Re: [Jprogramming] raze in

2011-09-23 Thread Marshall Lochbaum
A better representation is ((e.>)~/ ;) I didn't consider that the items inside the boxes of y could be boxed. Marshall On Fri, Sep 23, 2011 at 3:13 PM, Raul Miller wrote: > On Fri, Sep 23, 2011 at 3:06 PM, Marshall Lochbaum > wrote: > > It's equivalent to (e.&

Re: [Jprogramming] raze in

2011-09-23 Thread Marshall Lochbaum
It's equivalent to (e.&>~/ ;) : e. 2 3 4;3 4 5;1 2 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 1 1 (e.&>~/ ;) 2 3 4;3 4 5;1 2 1 1 1 1 1 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 1 1 So, it tells you which boxes (vertical axis) contain each element of the raze (horizontal axis). Marshall On Fri, S

Re: [Jprogramming] Welford's method for standard deviations

2011-09-16 Thread Marshall Lochbaum
There's obviously some sort of effect with floating-point rounding going on. Try this one out: r=:1e12+0.5-~1e6?@$0 plot 0 128 128; '(1e12-~mean@:(r&+))"0' r is a random distribution around 1e12, and here we plot the difference between the mean and 1e12 against the amount we added to r. It

Re: [Jprogramming] Consecutive Numbers in List

2011-09-16 Thread Marshall Lochbaum
; <@:(+/\)\. p:i.4 2 5 10 17 3 8 15 5 12 7 applies +/ on prefixes of suffixes. Marshall On Fri, Sep 16, 2011 at 12:59 PM, Roger Hui wrote: > Multiple applications of the infix x +/\ y does the trick. > > f=: >:@i.@# +/\&.> < > f 2 3 5 7 > ┌───┬──┬─┬──┐ > │2 3 5 7│5 8 12│10

  1   2   3   >