Re: [Jprogramming] String replacement question

2023-12-02 Thread Jan-Pieter Jacobs
The replace trick of Raul is nice. After my initially failed (like Aaron's) attempt to use replace, I solved the problem in a more array oriented way: p1 =: [: +/ ".@({.,{:)@:(#~e._j_);._2 num =: ;:'zero one two three four five six seven eight nine' fix =: [: ([: i:&1"1@|: 1,num

[Jprogramming] Getting in the mood for AoC

2023-11-14 Thread Jan-Pieter Jacobs
This year, I wanted to start AoC better prepared than other years, as I got pretty tired of tediously copying inputs by hand on Android. So I wrote a little library for structuring the code for implementing the solutions, getting (and caching) the personalised input, running and submitting

Re: [Jprogramming] Report of the J wiki group meeting of November 2, 2023

2023-11-13 Thread Jan-Pieter Jacobs
As to point 2), this is indeed something I have wondered about: Nuvoc is a great reference, but are changes by random people consistently checked for correctness (even if, one might assume, they are made in good faith)? On a related note, knowing for which version of J some explanation in NuVoc

Re: [Jprogramming] Primes with combination of same digits

2023-09-24 Thread Jan-Pieter Jacobs
Ha, I fixed my wrong solution of yesterday: cond=: # = [: (!@# % [: */ !@#/.~) 10 #.inv {. primegroups=.(#~cond&>) ( wrote: > pf 19 has at least 1 solution > > # 1 ,^:(0 =

Re: [Jprogramming] Primes with combination of same digits

2023-09-23 Thread Jan-Pieter Jacobs
Sept 2023, 09:13 Jan-Pieter Jacobs, wrote: > I would tackle it like this: > > primegroups =: (#~1<#&>)( > which starts from the list of primes under 1e6: i.&.(p:^:_1) 1e6 > > box those keyed by unique sets of digits: > > ( > and finally remove prim

Re: [Jprogramming] Primes with combination of same digits

2023-09-23 Thread Jan-Pieter Jacobs
I would tackle it like this: primegroups =: (#~1<#&>)() It looks like there are 4181 of such groups, with a total of 78160 primes. Jan-Pieter On Sat, 23 Sept 2023, 07:54 'Skip Cave' via Programming, < programm...@jsoftware.com> wrote: > Here's a verb p(n) to produce all n-digit primes with

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Jan-Pieter Jacobs
I think it would need specifying rank 0 and using /. m=: i. 5 4 3 0 2 {"0 2/ m NB. slices 0 2 at rank 2 0 1 2 12 13 14 24 25 26 36 37 38 48 49 50 6 7 8 18 19 20 30 31 32 42 43 44 54 55 56 slice =: {{ {"(0,m)/ }} NB. the same $0 2(3 slice) m 2 5 3 This way, the number of slices

Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.

2023-08-14 Thread Jan-Pieter Jacobs
Let me try to explain it : The moment J parses a number that is not followed by an x, it will never be an extended integer. This is irrespective of whether the number is parsed on the command line (J's term), via ". from a string, or from a script. Loosely speaking, whenever you want a typed-in

Re: [Jprogramming] Explicit to tacit conversion without repeating verbs

2023-08-10 Thread Jan-Pieter Jacobs
Hi, 1) Yes you can. Whether you should is another question: There's nothing wrong with explicit code, and aiming to forcibly make everything tacit is the way to a lot of frustration if you're trying to get things done, especially if 3 or more arguments are needed to be juggled. In most of such

Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial

2023-08-04 Thread Jan-Pieter Jacobs
I've been working on putting my solutions for the first 5 AoC days at https://code.jsoftware.com/wiki/ShareMyScreen#by_Jan-Pieter_Jacobs Any feedback would be appreciated, and if I don't get any, I'll just assume I'm doing great job and continue as is ;). As a side note: does anyone have code

Re: [Jprogramming] Syntax Highlighting: Special Combinations

2023-07-31 Thread Jan-Pieter Jacobs
In addition to the higlighting of correctly used special combinations, I think it would also be useful to highlight, or issue warnings for (as done for 9!:55) for near-misses, i.e. caused by phrases that could use a special combination, but miss it due to wrong or missing parentheses etc. My

Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial

2023-06-02 Thread Jan-Pieter Jacobs
Great initiative, Henry. I'm considering gradually adding my versions. How do you think it's best to structure this? One section per person with a list of pages for each problem, or put solutions of different persons close to each other? My solutions are still a work in progress, though;

Re: [Jprogramming] bug?

2023-06-01 Thread Jan-Pieter Jacobs
To phrase it a bit more verbosely: conjunctions have a long left reach, and a short right one. That is, if you'd fully parenthesise the phrase: a@b@c@d it would result in: (((a)@b)@c)@d for your phrase: (((i.3) & |.)"(0 _) ]) i.3 i.e. the left argument is bound before the right one comes in

Re: [Jprogramming] J - bootstrapped

2023-05-13 Thread Jan-Pieter Jacobs
I think you might be interested in this: https://code.jsoftware.com/wiki/PrimitivePrimitives Jan-Pieter On Sat, 13 May 2023, 16:33 Ian Clark, wrote: > The Weston Cell is an electricity source having no pretensions to being a > source of power, but just a stable voltage reference. I'm looking

Re: [Jprogramming] lp?

2023-04-05 Thread Jan-Pieter Jacobs
Depending on how complicated the function you're trying to approximate is, I'd take a look at a simple linear model (using %. ; take a look at the best fit lab), or a neural network (see e.g. the neural network example on the J Playground, which classifies 2d data). Another classifier often used

Re: [Jprogramming] distance makes the heart grow fonder

2023-04-01 Thread Jan-Pieter Jacobs
I'd be in favour of both .. and ... . Regarding ... , I'd like to note that Matlab uses the same as line joiner (see https://www.mathworks.com/help/matlab/matlab_prog/continue-long-statements-on-multiple-lines.html), and also turns everything after that into a comment (which is very handy). This

Re: [Jprogramming] J Console background

2023-03-25 Thread Jan-Pieter Jacobs
Hi Gilles, Welcome to the very deep rabbit hole that is J. In case you're referring to the JQt console/terminal, you can change colors as you see fit in the file config/styles.cfg open '~config/style.cfg' opens it in the editor for you. For JHS I have no clue since I barely use it.

Re: [Jprogramming] Jios & i(pad)OS 6.2?

2023-03-19 Thread Jan-Pieter Jacobs
I'm on IpadOS 16.3.1 and the last Jios version has no problems at first sight in my not-so thorough test. It runs, and both plot and viewmat work. Jan-Pieter Op zo 22 jan. 2023 om 09:59 schreef 'Mike Day' via Programming < programm...@jsoftware.com> > Chat or programming? > > Anyway, my iPad

Re: [Jprogramming] permutations

2023-03-17 Thread Jan-Pieter Jacobs
Probably it's just something going over my head, but how do these permutations have more than one cycle? #@C. _1 1 |."0 _ i. 128 1 1 C. y returns boxed cycles in permutation y. What am I missing? Jan-Pieter On Fri, 17 Mar 2023, 01:07 Marshall Lochbaum, wrote: > Interesting problem! I

[Jprogramming] Math/calculus simplify trig pull request

2023-02-24 Thread Jan-Pieter Jacobs
I was looking at Raul's pull request for math/calculus here: https://github.com/jsoftware/math_calculus/pull/5 . This would simplify a lot of derivatives, especially ones involving sines and cosines, which cause higher order derivatives to explode in the current version. I've been granted push

Re: [Jprogramming] Odd

2023-02-18 Thread Jan-Pieter Jacobs
.*)x: 4 4$_ __ 0 0 1 1 0 0 0 0 1 0 0 0 0 1 > > > On Fri, 17 Feb 2023 at 6:36 PM Jan-Pieter Jacobs < > janpieter.jac...@gmail.com> > wrote: > > > I recently had problems with GMP too on my AVX (not AVX2) laptop. > > They seem to be solved with the most recent beta. >

Re: [Jprogramming] Odd

2023-02-17 Thread Jan-Pieter Jacobs
I recently had problems with GMP too on my AVX (not AVX2) laptop. They seem to be solved with the most recent beta. With a fresh install from the install package "j904_linux64.tar.gz 2023-01-24 17:44 3.4M j904 linux 64-bit" from http://www.jsoftware.com/download/j904/install/ , I initially got a

Re: [Jprogramming] Atop parsing

2023-02-16 Thread Jan-Pieter Jacobs
ot;while". A simple test > code: increment while less than 8. (With some errors one need kill the > j session.) > > >: (^:^:_) (<&8) 2 > > 8 > > While=: ^:^:_ > > u. While v. > u.^:v.^:_ > > > Date: Wed, 15 Feb 2023 13:12:37 +

Re: [Jprogramming] Atop parsing

2023-02-15 Thread Jan-Pieter Jacobs
The reason it's hard to find anything else on modifier trains is that they have been removed from the language a long time ago (with j501 in 2002, apparently), and only reintroduced recently with j903. Before the reintroduction, the only modifier trains were bidents: - partially applied

Re: [Jprogramming] File Operations -> JMF Alternative

2023-02-03 Thread Jan-Pieter Jacobs
3!:2 just gives a representation of the noun. JMF memory-maps a file via the OS, so you can access the file's content as if it were just normal memory. It will stay only on disk as long as only in-place methods are used to change it (doing something like othervar=: +: mapped var will copy it

Re: [Jprogramming] File Operations

2023-02-02 Thread Jan-Pieter Jacobs
I think this could be of interest as well: https://code.jsoftware.com/wiki/Guides/Component_Files Component files allow to store multiple, different nouns to be saved as well. It's an addon named data/jfiles, you can load, once installed, using: load'jfiles' Best regards, Jan-Pieter On Thu, 2

Re: [Jprogramming] 904-beta-j

2023-01-22 Thread Jan-Pieter Jacobs
I don't know if anyone else tried, but after installing the latest android APK, supposedly beta-j, JVERSION still reports beta-i: JVERSION Engine: j904/j64arm/android Beta-i: commercial/2022-12-14T09:27:03 Library: 9.04.10 J Android: 1.4.23/13/33 Platform: Android 64 (arm64-v8a) Installer:

Re: [Jprogramming] (A n) new train. was: more fun with parallelism

2023-01-11 Thread Jan-Pieter Jacobs
I'd make A: a conjunction that, depending on u, returns a verb or an adverb: If u is a verb, assume v are a set of properties to set, either binary (a verb is commutative or not), or multi-valued with a defined default value. If u is a noun, then treat it as a set of property "keys" (fretted, as

Re: [Jprogramming] more fun with parallelism

2023-01-10 Thread Jan-Pieter Jacobs
Intuitively, to me it would make sense to have a conjunction, e.g. P., to set properties, provided as literal characters, to a verb (or, if it would become desirable for other use cases, for nouns as well), and a corresponding adverb (in line with b.) to query them. I bet there are other

Re: [Jprogramming] Examples of u . v where u is not a w/

2023-01-10 Thread Jan-Pieter Jacobs
Although I never used it, I can imagine using a Fold (F.. or F:.) instead of u/ in a dot product could be handy in some cases. This would allow early exit using Z: . Jan-Pieter. On Tue, 10 Jan 2023, 05:12 Devon McCormick, wrote: > Looking at about 300 examples of using dot in my own code, it

Re: [Jprogramming] Examples of the grade operator

2023-01-09 Thread Jan-Pieter Jacobs
How I use it quite often is in a hook for sorting by column, e.g. sort by the first column: ]tab=: 5 3 ?@$ 100 62 32 90 6 38 33 9 60 28 92 29 41 68 83 79 (/: {."1) tab 6 38 33 9 60 28 62 32 90 68 83 79 92 29 41 Of course, you could use any other verb returning #tab elements to be

Re: [Jprogramming] density plot tick marks misaligned

2022-11-04 Thread Jan-Pieter Jacobs
aybe it > would be better to use > >'density;noaxes' plot i.5 5 > > ? > > -- > Raul > > On Fri, Nov 4, 2022 at 4:36 AM Jan-Pieter Jacobs > wrote: > > > > Hi all, > > > > I noticed the tick marks in the plot addon's density plot are misaligned

[Jprogramming] density plot tick marks misaligned

2022-11-04 Thread Jan-Pieter Jacobs
Hi all, I noticed the tick marks in the plot addon's density plot are misaligned, e.g. load 'plot' 'density' plot i. 5 5 shows 5 coloured cells, and axes range from 0 to 4. But the corresponding tick marks are aligned to the left of the cell in column 0, and the right of the cell in column 4.

Re: [Jprogramming] J blind spot

2022-10-22 Thread Jan-Pieter Jacobs
particular case the tacit solution wins on elegance and (at least at > the moment) seems perfectly clear. > > Thanks again. > > Ed > > Sent from my iPad > > > On Oct 21, 2022, at 1:55 PM, Jan-Pieter Jacobs < > janpieter.jac...@gmail.com> wrote: > > > > I

Re: [Jprogramming] J blind spot

2022-10-21 Thread Jan-Pieter Jacobs
I don't know whether you'r only looking for a tacit function, but this would also likely work if fold is unavailable for you (untested): {{ for_val. y do. if. f val do. val_index{y return. end. end.}} coords Jan-Pieter On Fri, 21 Oct 2022, 19:51 Ed Gottsman, wrote: > Pascal, > > Your original

Re: [Jprogramming] symbolic J - how to tackle adv/conj

2022-10-15 Thread Jan-Pieter Jacobs
as equivalent classes later using rewrite rules does not seem difficult and preserves the original as well. Jan-Pieter On Sat, 15 Oct 2022, 02:24 Elijah Stone, wrote: > The whole point is to suss out semantics. Why leave them out? > > On Wed, 12 Oct 2022, Jan-Pieter Jacobs wrote: > &

Re: [Jprogramming] [Beginner] How to make a function using list pattern matching deterministic

2022-10-14 Thread Jan-Pieter Jacobs
I think you intended to send this to a different forum/mailinglist… It's for sure no J ;). Cheers, Jan-Pieter On Fri, 14 Oct 2022, 12:38 Razetime, wrote: > Currently I have these two predicates in my program that I think I can > make deterministic. > > :- pred entry(list(string)::in,

Re: [Jprogramming] symbolic J - how to tackle adv/conj

2022-10-12 Thread Jan-Pieter Jacobs
verbs: usually the user will have a particular valence in mind > and can specify that. But if you care: split the verb into monadic/dyadic > cases, apply to symbolic arguments, simplify, and then restore if necessary to > round-trip. > > > in + + + + +, all +'s would collapse to a sing

[Jprogramming] symbolic J - how to tackle adv/conj

2022-10-07 Thread Jan-Pieter Jacobs
Dear all, After recent discussion of the math/calculus addon, I started playing around with what could become a symbolic toolkit for J, which could in turn serve as a backend for other projects, like future versions of the math/calculus addon, explicit-to-tacit and vice versa, etc. It should thus

Re: [Jprogramming] math/calculus hooks and under

2022-10-04 Thread Jan-Pieter Jacobs
: > > On Fri, 30 Sep 2022, Jan-Pieter Jacobs wrote: > > > Ideally the simplifier should be called en-route, because the derivstg and > > family (doing differentiation on string representations) call themselves all > > the time, which is why in the current version, things l

Re: [Jprogramming] math/calculus hooks and under

2022-09-30 Thread Jan-Pieter Jacobs
Thanks for your interesting observations, Elijah. I replied in-line below. Best regards, Jan-Pieter On Fri, 30 Sept 2022, 06:38 Elijah Stone, wrote: > I have no control over the calculus addon, but I mark the equivalent > treatment > of &. and &.: and therefore would like to ask a clarifying

[Jprogramming] math/calculus hooks and under

2022-09-29 Thread Jan-Pieter Jacobs
Hi folks, Mostly as a heads-up: I just submitted a pull-request for the math/calculus addon which adds hooks, under, NVV forks and fixes some bugs. You can find it here: https://github.com/jsoftware/math_calculus/pull/9 . Any comments are highly appreciated! My main motivation for messing

Re: [Jprogramming] dyadic format customization request

2022-09-20 Thread Jan-Pieter Jacobs
Or also very close to your proposal: _7{.!.'0' ": 8 008 Cheers, Jan-Pieter On Tue, 20 Sept 2022, 16:50 Raul Miller, wrote: >1}.":1e7+8 > 008 > > FYI, > > -- > Raul > > On Tue, Sep 20, 2022 at 10:46 AM David Lambert > wrote: > > > > 7":!.'0'8 > > > > 008 > > > > Use:

Re: [Jprogramming] Draft reference card for J9.04

2022-08-11 Thread Jan-Pieter Jacobs
Great work again. It looks very impressive (aside of very dense, which is a good thing for a reference card). I have gone through it in detail, and learned a few corners of J I did not know yet. I made a list of remarks I had which, I see now, has grown considerably, but please take it as a sign

[Jprogramming] PR math/calculus informative errors

2022-08-06 Thread Jan-Pieter Jacobs
Hi, A few days ago I wrote an issue on Github [1] for opinions on more informative errors in math/calculus. Understandably, most people seem to have overlooked it. I now also wrote a pull-request [2] for you to try out and see whether you like the errors. For example: load 'math/calculus' NB.

Re: [Jprogramming] Poll questions: new refcard

2022-08-04 Thread Jan-Pieter Jacobs
Good job! I answered the poll in-line below: Op do 4 aug. 2022 om 17:02 schreef Henry Rich : > 1. In each document, look at a couple of tables with a footnote, and > refer to the footnotes. Which layout did you find easiest to use? > c. footnotes below each table (easier for on-screen viewing,

Re: [Jprogramming] strange request

2022-07-26 Thread Jan-Pieter Jacobs
I don't know whether you had this in mind, but another case (that I don't have a concrete example use of) is that of using @. with a vector of indices, rather than a single value, allowing to create trains. In this case, the gerund verbs can clearly have different result ranks, e.g. +/`%`-`# @.

Re: [Jprogramming] J Playground neural network demo

2022-07-14 Thread Jan-Pieter Jacobs
Tue, Jul 12, 2022 at 3:23 PM Jan-Pieter Jacobs < > janpieter.jac...@gmail.com> wrote: > > > Hi Joe, > > > > Apparently I indeed made a mistake in the NN example, I didn't duplicated > > the \ for on lines 317 and 339 of examples.js. This causes the intended \ > &g

Re: [Jprogramming] LaTeX question: J-boxed display

2022-07-13 Thread Jan-Pieter Jacobs
I haven't tried it personally, but this looks like it could be a good start: https://tex.stackexchange.com/questions/18600/expandable-nested-boxes-with-tikz which refers to: https://tikz.dev/library-shapes#sec-71.6 Otherwise, if he prefers manually making drawings for use in LaTeX, I have had

Re: [Jprogramming] J Playground neural network demo

2022-07-12 Thread Jan-Pieter Jacobs
a downloaded copy with a few tweaks). Thanks, Jan-Pieter Op do 7 jul. 2022 om 05:48 schreef Joe Bogner : > Hi Jan-Pieter, > > Thanks for all the feedback and the pull request. I merged it in. > > Below are some comments on your excellent feedback: > > On Sun, Jul 3, 2022 at 5:45

Re: [Jprogramming] "Dynamic" of J

2022-07-04 Thread Jan-Pieter Jacobs
Hi Meino, I wouldn't worry too much about changing syntax; most of it remained the same, except for cosmetic changes (e.g. not using x. and y. for arguments names but x, y) and behind-the-scenes implementation aspects (faster, more special code, in-place operations). Those generally don't change

Re: [Jprogramming] J Playground neural network demo

2022-07-03 Thread Jan-Pieter Jacobs
22 at 4:42 PM Jan-Pieter Jacobs < > janpieter.jac...@gmail.com> > wrote: > > > I had some fun putting J Playground through its paces and wrote the > > following neural network demo: > > > > > > > https://jsoftware.github.io/j-playgro

Re: [Jprogramming] Initial question

2022-07-03 Thread Jan-Pieter Jacobs
Hi tuxic, It's jconsole, wherever you installed that, if you only want CLI, otherwise you should use jqt. Jqt also has ways to hide the GUI from being shown, but I don't remember how. In case you installed from the .deb archive, jconsole will be called ijconsole. This page on the wiki might

Re: [Jprogramming] Problem with @ (Atop)

2022-06-27 Thread Jan-Pieter Jacobs
Hi Jacques, I think this link might be very interesting: https://code.jsoftware.com/wiki/Vocabulary/RankInfoIsImportant Best regards, Jan-Pieter On Mon, 27 Jun 2022, 14:23 Jacques Bailhache, wrote: > According to https://www.jsoftware.com/help/dictionary/d620.htm : > x u@v y ↔ u x v y > But :

Re: [Jprogramming] Fork does not work

2022-06-22 Thread Jan-Pieter Jacobs
Yes, I see. appliedTo is an adverb, because it's a partially applied conjunction, i.e. the result of applying conjunction @. to verb (]@1). When you apply appliedTo to mult, the conjunction is evaluated, i.e. mult @. (]@1). This gives you a domain error because @. expects a noun, specifically a

Re: [Jprogramming] A new episode of the ArrayCast podcast is available

2022-06-15 Thread Jan-Pieter Jacobs
ly... also relevant). > > Even so, it's nice to know the connection between Join and Transpose. > Thanks for the link—I've seen it but it didn't occur to me in this > context. > > Marshall > > On Wed, Jun 15, 2022 at 09:00:13PM +0200, Jan-Pieter Jacobs wrote: > > Hi, &

Re: [Jprogramming] A new episode of the ArrayCast podcast is available

2022-06-15 Thread Jan-Pieter Jacobs
Hi, I'd like to thank the entire Arraycast crew for this excellent podcast, I'm always looking forward to the next episode. I find it super informative, with a healthy dose of humour. Great job; please continue ;). Since you didn't seem to find many applications of dyadic transpose, I'd like to

Re: [Jprogramming] calculus horibilis

2022-06-07 Thread Jan-Pieter Jacobs
I think the implementation is correct, though it lets you use numbers larger than the specified base, and always returns an integer in base 10: 4b5 NB. 5 > 4 but no problem 5 4bz 35 This is the same behaviour as #. : 4 #. 5 5 4 #. 1 1 5 when using base specification using b, J lets

Re: [Jprogramming] J Playground neural network demo

2022-06-05 Thread Jan-Pieter Jacobs
(gethttp y) fwrite '~temp',(}.~ i:&'/')y > }} > EMPTY > end. > }}_ > > -- > Raul > > On Sat, Jun 4, 2022 at 4:42 PM Jan-Pieter Jacobs > wrote: > > > > I had some fun putting J Playground through its paces and wrote the > > following neural

Re: [Jprogramming] J Playground neural network demo

2022-06-05 Thread Jan-Pieter Jacobs
I'm entirely fine with including the NN example in the Playground menu. That's pretty much what I wrote it for, and I'm happy to contribute something useful. I have to say that much of the code clarity (at least much of the structure and concept) also comes from having started from the book

[Jprogramming] J Playground neural network demo

2022-06-04 Thread Jan-Pieter Jacobs
I had some fun putting J Playground through its paces and wrote the following neural network demo: https://jsoftware.github.io/j-playground/bin/html2#url=https://gist.githubusercontent.com/jpjacobs/6ff68c07bf764ad886e097ffbd19f5f0/raw/52b0563a7daa76df7fa57a3743da45ca0755f1a7/nn.ijs It dowloads

Re: [Jprogramming] Composite Item (m}y) with gerund m

2022-05-30 Thread Jan-Pieter Jacobs
I had some fun learning modifier trains recently (might post about my experiences later) and I came up with this adverb, based on Brian's second approach (no clue how to name it as I didn't bother understanding its purpose): adv=: ]: (]`(*@)`(,:([.].))}) 3&| adv ]`(*@(3&|))`(,: 3&|)} 3&|

Re: [Jprogramming] New in beta-d: multithreaded primitives

2022-05-22 Thread Jan-Pieter Jacobs
AS will > be about the same as that using 0 T. > otherwise using 0 T. instead of BLAS should be faster. > > > > On Sun, May 22, 2022 at 5:28 AM Jan-Pieter Jacobs < > janpieter.jac...@gmail.com> wrote: > > > That's very cool! > > > > A =: 3000 4000

Re: [Jprogramming] New in beta-d: multithreaded primitives

2022-05-21 Thread Jan-Pieter Jacobs
That's very cool! A =: 3000 4000?.@$0 B =: 4000 2000?.@$0 10 timespacex 'C =: A +/ .* B' 4.15287 6.71109e7 0@''^:4 '' 4 10 timespacex 'C =: A +/ .* B' 2.30104 6.71109e7 JVERSION Engine: j904/j64avx/linux Beta-d: commercial/2022-05-19T20:41:10 Library: 9.04.01 Qt IDE:

[Jprogramming] Dictionary addon update

2022-05-17 Thread Jan-Pieter Jacobs
Good morning, I updated my dictionary addon: https://github.com/jpjacobs/types_dict Now it has a lot more functionality: aside of just setting and getting values, there are also inter-dictionary operations such as merging by key; applying functions between values of corresponding keys, etc. The

Re: [Jprogramming] newbie question

2022-05-15 Thread Jan-Pieter Jacobs
actually, J lets you approximate pi to as many digits as you'd want, but you have to know the trick: pix =. ([: <.@:o. 10^x:) _10 ]\ ": pix 100 3141592653 5897932384 6264338327 9502884197 1693993751 0582097494 4592307816 4062862089 9862803482 5342117067 9 gives the first 101 digits of pi

[Jprogramming] Error messages & rethrowing

2022-05-12 Thread Jan-Pieter Jacobs
Hi, I have some questions on error reporting. I wrote this verb, I thought could be handy alongside the assert verb in the standard library: assertno =: 0 0$([ 13!:8~ ],~(LF,'| '),~ (9!:8'') {::~ <:@[)&>/@[^:(0 e. ]) it takes as x: error_number;'message', and as y the same as for assert (i. e.

Re: [Jprogramming] ~addons/math/deoptim/deoptim.ijs

2022-05-12 Thread Jan-Pieter Jacobs
I agree with you on locales causing troubles. Especially since some things just seem to go against the grain of J, i.e. don't work as expected. For instance today, I tried writing an explicit adverb that would need to execute in an object's locale. It didn't work, because once a verb is derived,

Re: [Jprogramming] J on IOS

2022-05-10 Thread Jan-Pieter Jacobs
e-tuning them is > something > > others can do far better than I can. Whereas Xcode, Objective-C, Swift > and > > UIKit seem to be skills in limited supply on the J forum. > > > > That I hope is something that will change. The last 2 years have seen > > Apple make

Re: [Jprogramming] J on IOS

2022-05-08 Thread Jan-Pieter Jacobs
Talking about IOS bugs (great app, by the way), I noticed that some sounds don't obey the silent mode (or whatever IOS calls that mode). I also couldn't find a setting to turn off the sounds in the app itself. I think ignoring silent mode could count as a bug, and an in-app toggle as a

Re: [Jprogramming] Bond mystery

2022-05-02 Thread Jan-Pieter Jacobs
Very curious indeed. Both j903 and j904 beta-c seem to behave well on this example. Have you tried it in a fresh session? Sometimes memory corruption could lead to strange results well after it occurred. Jan-Pieter On Mon, 2 May 2022, 08:31 'Rob Hodgkinson' via Programming, <

Re: [Jprogramming] Extended precision question

2022-04-28 Thread Jan-Pieter Jacobs
I actually was intending for quite a while to propose an extension to comments along the lines of the suggestions in this thread: to use ... as line continuation indicator that turns everything after it up to and including the next line break to be considered comment, and still considers the line

Re: [Jprogramming] If utility

2022-04-13 Thread Jan-Pieter Jacobs
I think your looking for power (^:), a conjunction though. +: ^: (2&|)"0 i. 8 0 2 2 6 4 10 6 14 which one could read as: double (+:) if (^:) odd (2&|) for each atom ("0) in the input (i. 8). Note that ^: is more general than "if": in u ^: v y, u is applied (v y) times. in the case of odd

Re: [Jprogramming] An invitation to participate in developing the J wiki

2022-03-10 Thread Jan-Pieter Jacobs
Hi, I tried it on Chrome for Android (12) but it doesn't work. The script loads, but when run is pressed, it fails :(. actually, j-playground always crashes in chrome, even when just waiting for a few seconds... Oddly, it does work in Firefox on the same device, Nice demo! Jan-Pieter On Wed, 9

Re: [Jprogramming] _. WAS A new bind conjunction WAS: Dictionaries

2022-02-08 Thread Jan-Pieter Jacobs
The biggest problem I see is finding a good use for such null value. In many cases where a null value would make sense, J/APL found a different way of making something useful out of what would otherwise be an error, e.g. 'abcX' {~ 0 1 2 i. 0 2 1 0 3 0 100 acbaXaX i. could return null if not

Re: [Jprogramming] Dictionaries WAS: Report on the J wiki meeting of January 27, 2022

2022-02-06 Thread Jan-Pieter Jacobs
Hi Pascal, I responded inline below: A workaround is to optimize SET, ADD, UPDATE, DEL for bulk operations > (multiple items processed at once (] F..) super useful), and after bulk > operations, "redefine" (just repeat execution of same definition) GET such > that any m updates. Also update

Re: [Jprogramming] Dictionaries WAS: Report on the J wiki meeting of January 27, 2022

2022-02-01 Thread Jan-Pieter Jacobs
Interesting discussion. My little addon (https://github.com/jpjacobs/types_dict ) works pretty well in my test, with any rectangular data (including boxes) as either keys or values. My only gripe with it was that due to subtle details of inverse in

Re: [Jprogramming] ArrayFire addon

2022-01-27 Thread Jan-Pieter Jacobs
Thanks for the explanation Hauke. I guess that shows that I never studied computer science. I expected rows and cols to just be indices of the non-zero items, as 4&$. returns for J's sparse arrays. Anyone else wondering can refer to https://en.m.wikipedia.org/wiki/Sparse_matrix where the CRS

Re: [Jprogramming] ArrayFire addon

2022-01-26 Thread Jan-Pieter Jacobs
Hi, I tried out the add-on, it looks very promising! After managing to install ArrayFire (apparently the logical "apt install" didn't work), I tried the basic tutorial and found the following line causes J to segfault when using the opencl backend: display_jaf_ afaiNB. get AF text

Re: [Jprogramming] Programming question

2022-01-23 Thread Jan-Pieter Jacobs
Hi Skip, When using n (or v) as names in a direct definition, it assumes you're defining a conjunction: F=.{{{.n#~y=+/\c1 n=.>:i.100}} F 19 F(19) type <'F' ┌───┐ │conjunction│ └───┘ FF=:{{{.nn#~y+/\c1 nn=.>:i.100}} type<'FF' ┌┐ │verb│ └┘ or you can

Re: [Jprogramming] Advent of Code Day 16

2022-01-18 Thread Jan-Pieter Jacobs
Hi, very interesting to read different takes on the problem! I made it recursive, passing around whatever remains of the bit string, with no use of global state (just some auxiliary verbs and the list of operations). A trick I was particularly happy with is combining the stopping condition on

Re: [Jprogramming] Advent of Code Day 15

2022-01-13 Thread Jan-Pieter Jacobs
ost path was circuitous like that. > > I hope this helps, > > -- > Raul > > On Wed, Jan 5, 2022 at 3:23 PM Jan-Pieter Jacobs > wrote: > > > > I started out with a classic J approach of shifting the array around, and > > keeping score in an array, ha

Re: [Jprogramming] Advent of Code Day 15

2022-01-05 Thread Jan-Pieter Jacobs
I started out with a classic J approach of shifting the array around, and keeping score in an array, having non-visited nodes set to max (2e9, rather than _ to keep the solution in the integer domain). NB. Day 15: Chiton navigation in=: [: freads '.txt' ,~ _2 {.!.'0' ": NB. read input of day y

Re: [Jprogramming] Advent of Code Day 14

2022-01-04 Thread Jan-Pieter Jacobs
Nice! It certainly interests me, although thorough analysis will have to wait till I get back to my PC. I think Raul's approach is similar, although mine, especially part B, is more complicated. NB. Day 14: Extended polymerization in=: [: freads '.txt' ,~ _2 {.!.'0' ": NB. read input of day y

Re: [Jprogramming] Advent of Code Day 13

2022-01-04 Thread Jan-Pieter Jacobs
Hi Raul, your version is indeed a very nice simplification of my amend cludge. Also a nice job on the parsing of the input. On Tue, Jan 4, 2022, 02:49 Raul Miller wrote: > Because I could have expressed this clearer, here's a complete > implementation of day 13, based on Jan-Pieter

Re: [Jprogramming] Advent of Code Day 13

2022-01-03 Thread Jan-Pieter Jacobs
Day 13 was sort of involved on the parsing part, and relatively easy on the actual solution. I kept the dots in the coordinate domain, as it seemed less heavy handed than converting it to "paper", the transform is also very easy in the coordinate domain. I used the dots as is, and encoded the

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Jan-Pieter Jacobs
Actually, 'in' is a wrapper for fread that reads the input file. I forgot to include it this time, sorry. It's defined as: in=: [: freads '.txt' ,~ _2 {.!.'0' ": NB. read input of day y (given as num) and I keep each day's input in a file named dd.txt, with dd the 2 digit day number. On Sun,

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Jan-Pieter Jacobs
I think mine is pretty much the same idea as Raul's for part 1, tough I used symbols rather than integers for encoding the caves (nodes). NB. Day 12: Cave mapping paths sl=: (\: #&>) NB. sort boxes by descending length NB. remove - and sort boxes by length s.t. start, end are first: unordered

Re: [Jprogramming] Advent of Code Day 11

2022-01-01 Thread Jan-Pieter Jacobs
My take on Day 11 followed roughly the same approach, but with a tacit step function. Likely, the solution verbs a11 and b11 could be made tacit as well, but as they're so simple, I did not bother. NB. Day 11: Bioluminescent dumbo octopus flashes i11=: "."0 ;._2 in 11 NB. how many flashes in 100

Re: [Jprogramming] Advent of Code Day 9

2022-01-01 Thread Jan-Pieter Jacobs
convergence) to understand how it worked. I would > never have arrived at that solution on my own. > > I learned a lot from your code. Thank you! > > Mike > > -- > Michael P. Manti > m...@mpmanti.info > > > On Dec 30, 2021, at 10:01, Jan-Pieter Jacobs > wrote: > &g

Re: [Jprogramming] Advent of Code Day 10

2021-12-31 Thread Jan-Pieter Jacobs
Hi, my take on day 10 followed the same idea as Mike, removing all paired brackets (for brevity, I use the term bracket for any of (){}[]<>), noting that corrupt lines have remaining closing brackets, while incomplete lines have only remaining opening brackets. I managed to make this one tacit

Re: [Jprogramming] Advent of Code Day 9

2021-12-30 Thread Jan-Pieter Jacobs
It's nice to see another take on the same problem. Differences with Raul's solution: for part A, I used shifted and padded versions of the array to find the minima's. For the basins, I did not use the lowest points, but just gave all points (not being edges = 9) a unique id, then assigned the max

Re: [Jprogramming] Advent of Code Day 8

2021-12-29 Thread Jan-Pieter Jacobs
Very nice read Raul! This time I took a different approach: I used the 1 and 7 characters to find the top segment and the two possible right segments, and bruteforced the remaining combinations. I used the standard segment ordering ( https://en.m.wikipedia.org/wiki/Seven-segment_display) rather

Re: [Jprogramming] Advent of Code Day 7

2021-12-28 Thread Jan-Pieter Jacobs
I took pretty much the same approach as Raul (i.e. bruteforce), but expressed it tacitly: NB. Day 07: Crab alignment NB. find position globally closest to all input numbers, each step being 1 fuel unit i07=: ".}:freads'07.txt' irg=: <./ ([+i.@>:@-~) >./ NB. integer range spanning the range

Re: [Jprogramming] Advent of Code Day 6

2021-12-28 Thread Jan-Pieter Jacobs
My take on Day 6 was similar to Raul's second part's solution. I did it tacitly though: I realised no fish would ever have an age >8, so I kept the number of fishes for each age in an array, i.e. n{state is the number of fishes at age n (see enc below). Then each step rotates the fishes and adds

Re: [Jprogramming] sorting up and up

2021-10-22 Thread Jan-Pieter Jacobs
Raul, Your solution works for i: 10, but not in the general case, e.g. a random permutation of i:10: (/: 3|3+*) ({~?~@#) i: 10 0 9 3 7 2 4 1 6 10 5 8 _9 _2 _10 _4 _1 _3 _7 _8 _5 _6 (/: 0&>)@/:~ ({~?~@#) i: 10 0 1 2 3 4 5 6 7 8 9 10 _10 _9 _8 _7 _6 _5 _4 _3 _2 _1 Best regards, Jan-Pieter

Re: [Jprogramming] sorting up and up

2021-10-22 Thread Jan-Pieter Jacobs
I would do: (/: 0&>)@/:~ i: 10 which makes use of sort being stable. On Fri, Oct 22, 2021, 12:20 ethiejiesa via Programming < programm...@jsoftware.com> wrote: > Sort and rotate? > >(|.~ +/@:<&0)@(/:~) _10+10?.@$20 > 4 6 6 6 9 _5 _4 _4 _2 _2 > > > Elijah Stone wrote: > > This is

Re: [Jprogramming] histogram verb

2021-10-19 Thread Jan-Pieter Jacobs
Hi Skip, I would do it as follows: hist1 =: bins ([,: _1 + #/.~@,) ] bins =: i.@:>:@(>./) this basically prepends the expected bins to the data, and subtracts one (_1 +) from the count. The definition of the bins might need to be adapted, based on your data; now it simply take 0 - highest

[Jprogramming] Tacit trains o. inverse

2021-10-14 Thread Jan-Pieter Jacobs
Hi all, I found a use for tacit trains today: making circle verbs with a sensible obverse: oi =: (& :. ({{-m}} & ].)) o. 1 oi 1 :.(_1) Nice, but I have a question: How does one make the {{-m}} part tacit? Or more general, how to make verbs operate on nouns and use their results in a tacit

Re: [Jprogramming] J903-beta-u

2021-10-03 Thread Jan-Pieter Jacobs
Thanks Bill, I was about to ask about the Android version as well. I did run into something strange though, can it be the jconsole packaged with the beta apk is still j902-Release-a? I generally run jconsole via termux on my phone (since it's less prone of being preempted, and it works better

  1   2   3   >