Questions tagged [j]
J is a high-level, general-purpose, high-performance array programming language.
396
questions
3
votes
2answers
81 views
Write 4 : 'x&{.&.;: y' tacitly
Conor Hoekstra recently solved a Leetcode problem in APL https://youtu.be/QtvvQ7MdwKY The problem is to take the first x words from a character string y
In J, using &. (Under) and ;: (Words) I can ...
4
votes
2answers
57 views
Sorting words in a string by their length in J
I have the following string:
s=:'when can we dance'
I can find the length of each word with this:
# each ;:s
I can sort the lengths in ascending/descending order:(/:~) # each ;:s which gives me boxed ...
3
votes
1answer
54 views
Amend with multiple indices per substitution in J
In J, how do you idiomatically amend an array when you have:
substitution0 multipleIndices0
...
substitutionN multipleIndicesN
(not to be confused with:
substitution0 multipartIndex0
...
...
2
votes
1answer
76 views
How can I take the outer product of string vectors in J?
I'm trying to replicate the outer product notation in APL:
∘.,⍨ 'x1' 'y1' 'z1' 'x2' 'y2' 'z2' 'x3' 'y3' 'z3'
which yields
x1x1 x1y1 x1z1 x1x2 x1y2 x1z2 x1x3 x1y3 x1z3
y1x1 y1y1 y1z1 y1x2 y1y2 y1z2 ...
4
votes
2answers
80 views
Is there an idiomatic way to print a vector(list) or a character string diagonally in J?
if I have a list a=:i.5, can it be printed like this(diagonally):
0
1
2
3
4
or in the case of a string like 'enigmatic' can a 'x' pattern be generated?
e e
n n
i i
g g
...
3
votes
1answer
85 views
Index of minimum element using J
In J it is trivial to find the minimum element of an array:
<./ 5 6 4 9
4
But how to find the index of the minimum element using J?
(In case this is an XY problem, I should say that I want the ...
1
vote
3answers
87 views
J programming how to wait fo X seconds before executing the next verb?
I want to wait for X seconds before executing the next line in a verb.
So far, I have tried this foreign command 6!:3 (2.5) found in time (delay) though it looks like the entire verb execution is ...
2
votes
1answer
108 views
How to reshape data array from wide to long in J?
I like to replicate the reshape function in J.
For example, Stata can reshape a dataset "from wide to long". Below is their Example 1 from their documentation:
. use http://www.stata-press....
3
votes
4answers
93 views
Run J script as if it were line-by-line entered into the interpreter
Is there a way to run the script as if it were typed into the interpeter? The benefits are that I don't need echos everywhere, the work done is saved as a file, and I can use vim to do the editing. ...
2
votes
1answer
42 views
Print values and it's associated index when working with vectors / matrix in J
If I want to check how many values in a vector or matrix are less than a given value
I can use +/ (a < 20). But what if I wanted to know both the specific value and it's index.
Something like (2(...
1
vote
1answer
49 views
where is the official documentation for .Alpha_j_
David Lambert's code here gets the letters (Alphabet), using the following:
26}.Alpha_j_ NB. output is abcdefghijklmnopqrstuvwxyz
Where can I find the offical documentation for ".Alpha_j_"...
2
votes
0answers
68 views
Is it possible to store boxed arrays as memory mapped files in J?
I have data that works well in j files and key files but for possible performance reasons memory mapped files make more sense. At one time J did have MMF's for boxed arrays but I think it was ...
0
votes
1answer
62 views
How to apply same fetch x value to different cells in structured array
For a 3 row array of a boxed structure e.g. q
]q=: ,. (0;'At least one uppercase letter';'At least one special character from "#$%^"';'Must be 10 to 30 characters long') ; (1;'...
1
vote
2answers
115 views
How to configure org mode to evaluate J code blocks?
When I run a J code block in org mode the java jconsole pops up instead. So must be sending a jconsole command instead of ijconsole... Of course J code block is not evaluated.
How do I fix this so ...
1
vote
1answer
57 views
atomic representation of a sentence for noun initialization
In a data structure such as
I want to be able to use ". (do) to initialize what could be a long list of noun names on the left with the values on the right in a nested array. A value could be a ...
3
votes
1answer
128 views
What is the most efficient way to insert a number into an ordered array?
Inserting numbers into a sorted array is a very common need.
Mathematica stack exchange for reference. Its priority queue appears extremely fast.
https://mathematica.stackexchange.com/questions/224249/...
1
vote
1answer
142 views
Seeking example that use the J programming language JHS web server as a service
The J programming language includes an embedded web server called JHS. The binary download comes with (on the mac) an app called jhs.app, which is, I think, intended to run JHS. However, there is no ...
2
votes
1answer
91 views
How can I manipulate/extract info from the following table in J
]data=:_3 ]\ 'Jack';23;178;'Rick';27;181;'Alice';41;178;'Mitch';31;184;'Paul';32;179
┌─────┬──┬───┐
│Jack │23│178│
├─────┼──┼───┤
│Rick │27│181│
├─────┼──┼───┤
│Alice│41│178│
├─────┼──┼───┤
│Mitch│31│...
4
votes
1answer
94 views
Write `4 : '$ x (<") y'` tacitly
How can I write the frame function tacitly? (From "Learning J" Ch 7)
I'm using the f x g y = x f@:g y composition scheme from Ch 8 , but it's not working. My guess is because <" has ...
1
vote
2answers
59 views
Just built j902 from source on osx, seeking confirmation that broken tests are “ok”
I have been using J for a few weeks and absolutely loving the new way it makes me look at old problems. I installed the ODBC drivers for Osx (10.15.6) but I get pointer violations:
[sean]% jconsole
...
1
vote
2answers
77 views
How to work with command line arguments in J
In J console mode if I type ARGV I get the full path of jqt.exe But when I try to pass some strings to a J script file I get 'syntax error' or 'domain error'. How does argument passing and retrieval ...
3
votes
1answer
126 views
Plotting a column of precision floating point values
I have a sequence of data that I have modified to the following:
load 'tables/csv'
load 'graphics/plot'
x =: readcsv 'table_ctl.csv'
dat =: 4 {::|:x
dat
The data in question is pulling the fourth ...
1
vote
1answer
70 views
Add ordinal number column to output of custom verb in J
If I type !i.10 it gives the factorial of first 10 numbers.
However if I try to add a column of ordinal numbers >/.!i.10, 1+i.10, then J freezes or I get an "Out of memory" error. How do ...
2
votes
2answers
58 views
How to use lbfgs from math/lbfgs?
I'm trying to use the function lbfgs_jlbfgs_ but cannot find a documentation. A naive approach to call this function without arguments gives
'"/usr/share/j/9.01/addons/math/lbfgs/lib/liblbfgs.so&...
5
votes
1answer
128 views
Applying multiple functions to each line of the input
I have 2 normalization functions: norm1 and norm2.
norm1 =: (- <./) % >./ - <./
norm2 =: %(>./@:|)
I want to apply these two functions to each line of the following input like this:
...
1
vote
1answer
99 views
In J, how do we generate a list of numbers that come from a normal distribution with a specified mean and variance
In J, I know that we can generate a list of uniform random numbers, and use some sort of inverse function to have a list of normal distribution number. But is there a quick way to achieve this?
3
votes
1answer
72 views
Is there a Cubic Spline Interpolation method implemented in J?
I am a new user of J and I am just wondering if there is a Cubic Spline Interpolation method implemented in J packages?
3
votes
1answer
77 views
Composing addition and division verbs over lists
If data =: 3 1 4 and frac =: % +/, why does % +/ data result in 0.125 but frac data result in 0.375 0.125 0.5?
3
votes
2answers
100 views
Creating y shape random float array in J
I am trying to creating y shape random float array, and this is my current right now:
input_dim =: 2
hidden_dim =: 16
0 ?@$ ~ (input_dim, hidden_dim)
0.838135 0.96131 0.766721 0.420625 0.640265 0....
3
votes
1answer
85 views
How do I arbitrarily compose dyadic functions while bonding one side of their arguments in J?
I have a dyadic function, call it f, that consumes a number and an array and outputs another array. For example:
0 f x_0
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ...
2
votes
1answer
51 views
Is font configuration available in jhs(J HTTP Server)?
I use J in my chromebook with the help of crouton.
Because I couldn't set the gtk environment for J gtk in my chromebook,
I usually launch jhs in my chrome browser.
Overall I am so satisfied with ...
2
votes
1answer
123 views
Using command-line arguments in J
I know that ARGV represents the arguments. Can I type arguments after the filename in jqt.exe or does that only work in jconsole.exe. Executing the code regarding ARGV given in the J docs crashes J on ...
2
votes
3answers
178 views
I am trying to do some basic math with files in J
I have a file with numbers separated by space (not a csv file but plain text file) The following code will sum the numbers appearing in a continuous line.
+/ 0". 1!:1 < F
(0". is for converting ...
1
vote
1answer
90 views
Trying to install jqt, it says link group is broken
The error message I get when jqt is run is libjqt.so.9.01: cannot open shared object file: No such file or directory
before this, it said the link group was broken.
Running Debian Bullseye amd64
1
vote
2answers
150 views
Generate a random integer array with repeating values in J
I want to generate a random array with repeating values. Something like this:
4 11 6 3 5 4 16 11 26 5 4
I know that the statement 12 ? 50 will generate a random integer array with 12 unique values ...
3
votes
1answer
121 views
Each prior adverb in J
In Q/kdb you can modify a verb easily with ': which represents each-prior. It will apply the verb to an element and it's previous neighbor. For example
=': checks if pairs of values are equal. In J, ...
2
votes
1answer
91 views
Running J scripts via command prompt on Win 10
How can I run J scripts from the console (cmd.exe or Powershell).I tried to set the path to jconsole.exe in Environment Variables but when I tried to launch it via cmd.exe, I get an error message that ...
4
votes
0answers
92 views
How to implement minikanren 'appendo' in J/APL?
I've been trying hard to implement Minikanren in J,but after making good progress up to lazy streams, conjunction, disjunction, and equivalence constraints, I am now completely stuck on the appendo ...
2
votes
2answers
138 views
Print an equilateral triangle in J language
I a trying to print a equilateral triangle to the console screen.
this is what I could find
]\ 'hello' NB. which prints
h
he
hel
hell
hello
2
votes
1answer
88 views
How to do an asof timeseries join in J/Jd
Is there a simple/efficient way to do an asof join in Jd? For example, given tables A and B with columns time/measurement, query for A.time,A.measurement,B.measurement where B.measurement is the last ...
3
votes
1answer
79 views
Why do two similar J verb phrases work, but only one of them works with the dynamic power conjunction?
The verb chain ''-:] works the way I would expect.
(''-:])''
1
(''-:])'non-empty'
0
It also works the way I expect with the dynamic power conjunction.
'empty'[^:(''-:])''
empty
'empty'[^...
3
votes
2answers
219 views
J programming language (E)BNF
I'm writing a paper for my Programming Languages and Compilers course about the J programming language. Since it's a relatively unknown (but interesting) programming language, I'm having trouble ...
5
votes
2answers
238 views
How to calculate f1(f2(…fn(x)…)) given a gerund?
One can calculate f1(f2(f3(x))) as
*: +: >: 4 NB. 100
Given a gerund of "unknown" length (eg. m1 =: *:`+:`>:, or m2 =: +:`>:) how can one calculate f1(f2(...(fn(x)) ...))?
...
4
votes
1answer
166 views
Exponential moving average in J
I currently am going through some examples of J, and am trying to do an exponential moving average.
For the simple moving average I have done as follows:
sma =: +/%[
With the following given:
5 ...
1
vote
2answers
96 views
Scatter plot in J
How do you create a scatter plot in J?
I can see how to easily create a line plot.
load 'plot'
plot i. 10
I have a hunch it has something to do with the jzplot class and the pd verb, but after ...
3
votes
1answer
89 views
Creating a scatterplot matrix with J
I am doing some data science on the commandline and discovered J as handy tool for basic analysis (statistics) tasks. After gaining some initial feeling for the language some years ago, I have to ...
2
votes
2answers
177 views
How do you run a standalone ijs j file on Linux?
I have been using j for a few weeks now and loving it. However, all of my work has been in the ijconsole. Does j provide a way to run .ijs files without using load? Similar to how you can simply run $...
1
vote
1answer
93 views
Create a matrix with random numbers when required shape is derived from other variables
I want to create a matrix with random numbers in J programming language when the required shape is derived from other variables.
I could create such a matrix with ? 3 5 $ 0 if i specify its shape ...
1
vote
1answer
115 views
“reduction on infixes” in Racket?
I am working on a compiler pass and want to remove redundant movq instructions. For example, this list:
((movq a b)
(movq b c)
(movq c d)
(movq d e))
should become ((movq a e)).
Likewise, the ...
3
votes
1answer
166 views
What does the `0".>,.2}.` part do in the J-script?
Recently I had the glorious idea to use J as a scripting language (otherwise I will never use J anywhere). The sample from the jsoftware page works as promised. Here for reference the code for ...