[Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread Pawel Jakubas
Dear J enthusiasts, What is your recommended way to call linux command/invoke program from J and capture result? Let's say I want to invoke *dd if=/dev/urandom bs=100 count=1* Could you point me to example showing how to deal with bigger streams in J, ie. process the source by chunks. Thanks a l

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread bill lam
J built in primitives can only work with regular files. Those can be seek to the end. If it is then you can use index read or map the file to a J noun. See memory mapped file lab or documentation. On Fri, 24 Jun 2022 at 5:10 PM Pawel Jakubas wrote: > Dear J enthusiasts, > > What is your recomm

Re: [Jprogramming] Sudoku16

2022-06-24 Thread 'Michael Day' via Programming
Sorry for late posting - apparently a problem with my broadband provider's server. Yes, it can be worth doing a limited feasibility check on your input.  Every column, row and small box should have no repeated elements apart from the "missing" indicator,  such as 0 or perhaps one of '.-*0' , 

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread Raul Miller
But, in addition to J's built in primitives, you can use code in "dlls" (*.so files, on Linux). See, for example: https://code.jsoftware.com/wiki/Guides/DLLs/Calling_DLLs Thus, for example, you could use libc's fread if you wanted. -- Raul On Fri, Jun 24, 2022 at 5:56 AM bill lam wrote: > > J

Re: [Jprogramming] Sudoku16

2022-06-24 Thread Raul Miller
I went to a "print out the hexadoku page" on that site, and did a right click save-as on the resulting html page. Extracting the puzzle seems straight forward (but beware email induced line wrap): htm=: fread '~/Downloads/16x16 sudoku, Hexadoku puzzle to print_ level beginner, #1.html' extract=:

Re: [Jprogramming] Sudoku16

2022-06-24 Thread 'Mike Day' via Programming
Perhaps I was just unlucky, but I tried an iPad-type “share” to Documents, which didn’t produce a useable file; later downloaded a pdf with the Windows 11 laptop. Copy-paste from adobe worked to the extent that multi-spaces became single spaces, which I then filled out by hand! Anyway, I’ll

Re: [Jprogramming] Sudoku16

2022-06-24 Thread 'Mike Day' via Programming
Ahhh... I hadn’t spotted “hexadoku” - I’d used “alphadoku”. We shall see in due course! M Sent from my iPad > On 24 Jun 2022, at 12:24, 'Mike Day' via Programming > wrote: > > Perhaps I was just unlucky, but I tried an iPad-type “share” to Documents, > which didn’t produce a useable file;

[Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread Pawel Jakubas
thanks for the pointers. I will know now how to deal with shared libraries. But what about the example I gave, ie. "*dd if=/dev/urandom bs=100 count=1*" ? How to invoke it in a simpliest possible way? Kindest regards, Pawel -- F

Re: [Jprogramming] Sudoku16

2022-06-24 Thread Brian Schott
Mike, To check the inputs of a grid I found that Hui's verb 'ok' works for me. Your revision of the verb 'solve' looks problematic to me because it suggests there is a dyadic version, but I could only find a monadic version from your earlier post. Also there is an example in this post using a ver

Re: [Jprogramming] Sudoku16

2022-06-24 Thread Brian Schott
Raul, Your script for parsing the printed grid looks very effective, but I could not find an example html page at https://www.sudoku-puzzles-online.com/ to try it with. Instead I found a page like the following one and simply selected/highlighted the grid from the screen and copy-pasted that into

Re: [Jprogramming] Sudoku16

2022-06-24 Thread 'Mike Day' via Programming
Sorry, Brian. I thought I’d removed the h from solveh- the h was for Hui, but not relevant for the version I prepared for this example. I had another “solve” in a larger script. As for the dyadic version, the line below solve =: 3 : 0 , and before the : line, shows a default lhs argum

Re: [Jprogramming] Sudoku16

2022-06-24 Thread Brian Schott
Mike, What I mean is, I never saw a line starting with : in your solve script. Maybe I missed a script or email somewhere? On Fri, Jun 24, 2022 at 1:31 PM 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > Sorry, Brian. I thought I’d removed the h from solveh- the h was for > Hui,

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread Raul Miller
require 'task' shell 'dd if=/dev/urandom bs=100 count=1' I hope this helps, -- Raul On Fri, Jun 24, 2022 at 9:33 AM Pawel Jakubas wrote: > > thanks for the pointers. > > I will know now how to deal with shared libraries. > > But what about the example I gave, ie. "*dd if=/dev/urandom bs=100 c

Re: [Jprogramming] Sudoku16

2022-06-24 Thread Raul Miller
Brian: the html page I saved was the html from the https://www.sudoku-puzzles-online.com/cgi-bin/hexadoku/print-a-grid-hexadoku.cgi page which in turn was generated from the [print] button at https://www.sudoku-puzzles-online.com/hexadoku/print-hexadoku.php Looking at view-source:https://www.sudo

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread neitzel
Pawel Jakubas asked: > > What is your recommended way to call linux command/invoke program > from J and capture result? Let's say I want to invoke > *dd if=/dev/urandom bs=100 count=1* NB. 2!:0 returns stdout, stderr goes to the console s =. 2!:0 'dd if=/dev/urandom bs=100 count=1' 1+0

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread David Lambert
   2!:0'dd if=/dev/urandom bs=100 count=1' 1+0 records in 1+0 records out 100 bytes copied, 0.000193284 s, 517 kB/s @�!" `�)��fg� ┬��R �`�D��w��r�Ĵ+�H��H� ;┘h`(wB�wS��̎�� J�$�F��`3��<`/�[��X@�l=��ٝe�y�� |Date: Fri, 24 Jun 2022 11:12:11 +0200 |From: Pawel Jakubas |To: programm...@jsoftwa

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread Raul Miller
On Fri, Jun 24, 2022 at 4:12 PM wrote: > NB. 2!:0 returns stdout, stderr goes to the console > s =. 2!:0 'dd if=/dev/urandom bs=100 count=1' ... Thanks, I keep forgetting that 2!:0 works on linux. (I guess it's kind of a mess that we have to use require'task' for windows.) Thanks again,

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread David Lambert
A slightly more careful addition to prior message.  I'll guess that stderr was displayed, not caught by the shell command &> .       A=:2!:0'dd if=/dev/urandom bs=100 count=1' 1+0 records in 1+0 records out 100 bytes copied, 6.2358e-05 s, 1.6 MB/s    datatype A literal    a.i.A 133 162 11 135 17

Re: [Jprogramming] calling linux command and dealing with streams

2022-06-24 Thread Raul Miller
If you do not want the stder messages, you can use 2>/dev/null in your command line: #A=: 2!:0'dd if=/dev/urandom bs=11 count=1 2>/dev/null' 11 FYI, -- Raul On Fri, Jun 24, 2022 at 5:30 PM David Lambert wrote: > > A slightly more careful addition to prior message. I'll guess that > stder

Re: [Jprogramming] Sudoku16

2022-06-24 Thread 'Michael Day' via Programming
It looks as if some line-wrapping hid the singleton " : " at the end of the preceding line. Sorry I didn't spot it! M On 24/06/2022 18:37, Brian Schott wrote: Mike, What I mean is, I never saw a line starting with : in your solve script. Maybe I missed a script or email somewhere? On Fri, Jun

[Jprogramming] The 30th episode of the Array Cast podcast is out.

2022-06-24 Thread 'robert therriault' via Programming
In this episode, a behind-the-scenes look at the Array Cast podcast. Host: Conor Hoekstra Panel: Adám Brudzewsky, Stephen Taylor and Bob Therriault. https://www.arraycast.com/episodes/episode30-our-first-year Cheers, bob -- Fo