[Jprogramming] J-ArrayFire

2022-02-02 Thread William Szuch
Multiplication of an integer array I get an error: AAA =: af_create_array_jaf_ i. 4 4 get_jaf_ AAA 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 =: af_matmul_jaf_ AAA,AAA |af cd call error result: assert | 'af cd call error result' assert 0[LASTERROR=:(":0{::r),' ',(x{.~x i.' '),' ',af_err_to_string

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Gilles Kirouac
Standard Library is also an item of the Help menu in JQT. ~ Gilles Le 2022-02-02 à 18:03, chris burke a écrit : I didn't even know there was a standard library The standard library docs are linked from System on the wiki left menu: https://code.jsoftware.com/wiki/Standard_Library/Overview O

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread chris burke
> I didn't even know there was a standard library The standard library docs are linked from System on the wiki left menu: https://code.jsoftware.com/wiki/Standard_Library/Overview On Thu, Feb 3, 2022 at 3:32 AM 'Viktor Grigorov' via Programming < programm...@jsoftware.com> wrote: > Thank you fo

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
For what it's worth, here's an hmac with a more production-oriented design: hmac=: {{ NB. https://en.wikipedia.org/wiki/HMAC NB. u: hash function (on literal sequence) NB. n: block size for hash if. 0=#(u'')-.,hfd i.16 do. v=. a. {~ _2 dfh\ u else. v=. u end.{{ NB.m: key

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

2022-02-02 Thread Elijah Stone
Set a flag on x. Check it at the same time you check whether the usecount is 1 to perform an in-place operation. If the operation is one of a few interesting ones (catenate, amend), look up the corresponding hash table and update it too. Otherwise discard the hash table. (As for where to pu

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
Hmm... https://wiki.jsoftware.com/wiki/Guides/UnicodeGettingStarted mentions hfd and dfh. At one point, dfh and hfd were part of the 'convert' addon. This has since been incorporated into the base library (and require'convert' succeeds, for backwards compatibility purposes, but does nothing). We

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread 'Viktor Grigorov' via Programming
Thank you for that, I see the issues in my attempt. Two comments perhaps more pertinent to the people attempting to revitalize the wiki: how is one to know: - that arbitrary(?) base numberal to decimal exist, matching the regex '\d+b_?\w+'? - how is one to know of the existence of hdf/dfh?---I d

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

2022-02-02 Thread 'Pascal Jasmin' via Programming
the important detail is that m&i. uses a static snapshot of m at the time that & is executed/bound. 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 sa

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
Here's an implementation of the hmac algorithm which supports using an somewhat arbitrary hash function (I have assumed that the hash produces a literal result, as opposed to a bit stream, a large arbitrary precision integer or a sequence of integers representing bytes), but other than that optimiz

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
The algorithm works with raw binary -- it will not be the case that all bytes will have ascii graphics. And, that relates to the other problem with your implementation: you are using a hexadecimal representation of a binary result as if it were equivalent to that binary result. I hope this makes

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
On Wed, Feb 2, 2022 at 7:37 AM Scott Locklin wrote: > I wrote this a couple of years ago. It's a bit more bit fiddly, and I know > it works as it was used in production to talk to an exchange. > > NB. hmac signature > NB. x key, y needs signature > NB. key may need to be made raw first > hmac=: 4

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread 'Viktor Grigorov' via Programming
I tried padding with 0 0 1 1 0 0 0 0 ('0') and with 0 0 0 0 0 0 0, and with your padkey function, but I don't get the proper results. Also, the 0x5c and 0x36 from the ascii table correspond to '/' and '6', yours results in ungraphable members. You said other issues exist as well, I would appreci

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Scott Locklin
I wrote this a couple of years ago. It's a bit more bit fiddly, and I know it works as it was used in production to talk to an exchange. NB. hmac signature NB. x key, y needs signature NB. key may need to be made raw first hmac=: 4 : 0 key=. x,(128 - #x) # 0{a. ixorkey =. ((22 b.)&(16b36) a. i.

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
Actually, for the general case, the hash function may have an output size smaller than the block size. So: padkey=: {{ if.x < # y do. y=. u y end. x{.y,x#{.a. }} FYI, -- Raul On Wed, Feb 2, 2022 at 6:51 AM Raul Miller wrote: > > On Wed, Feb 2, 2022 at 4:41 AM 'Viktor Grigorov' via Progra

Re: [Jprogramming] HMAC and PBKDF2

2022-02-02 Thread Raul Miller
On Wed, Feb 2, 2022 at 4:41 AM 'Viktor Grigorov' via Programming wrote: > I wanted to see if J could be faster than bespoke C programs (specifically > aircrack-ng, ~10k/s on my machine). > From the wiki pages for SHA1 (turns outs there exists a foreign so I dropped > it), HMAC, and PBKDF2I assem

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

2022-02-02 Thread Henry Rich
That's a possibility, but how would you know when x changes, or is assigned to a different name? Henry Rich On 2/1/2022 8:27 PM, Elijah Stone wrote: On Mon, 31 Jan 2022, Henry Rich wrote: The deficiency in J is that m&i. gives you a hashtable for searching m, but if you modify m you have to

Re: [Jprogramming] Advent of Code Day 23

2022-02-02 Thread Raul Miller
My solution there was also quite verbose. Golfing an implementation might be a worthwhile exercise. Thanks, -- Raul On Wed, Feb 2, 2022 at 6:15 AM 'Michael Day' via Programming wrote: > > More chat on this old thread. > > Finished at last! 50 stars for something or other... > It took quite a

Re: [Jprogramming] Advent of Code Day 23

2022-02-02 Thread 'Michael Day' via Programming
More chat on this old thread. Finished at last!  50 stars for something or other... It took quite a lot of tweaking to build in the restrictions to the "amphipods' " movements that I'd mentioned in my msg of 23Jan, below. I'd overlooked the paragraph (originally without J's NB. as Raul pointed

Re: [Jprogramming] Sierpinski triangle

2022-02-02 Thread Andrew P
Xash: (3 ({. ~: {:)\ 0,],0:) That's brilliant! It only took me 5 minutes to understand what this means this time :-) Elijah: Thank you for the clarification. The adverb rule is foreign to me, I will have to explore some examples to see why it makes sense for it to be different from the verb rule.

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

2022-02-02 Thread Aaron Ash
I’ve successfully tested it on linux at least, looking through the source though it looks like it only reads from parquet at the moment, I must not have tested writing yet. The bindings aren’t too complex though, it might be straightforward to add a writeParquet verb if that functionality is still

[Jprogramming] HMAC and PBKDF2

2022-02-02 Thread 'Viktor Grigorov' via Programming
Hello, I wanted to see if J could be faster than bespoke C programs (specifically aircrack-ng, ~10k/s on my machine). From the wiki pages for SHA1 (turns outs there exists a foreign so I dropped it), HMAC, and PBKDF2I assembled: sha1=:1&(128!:6) bs=:512%8 NB. block size in bytes for md5, sha1, sh

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

2022-02-02 Thread Ric Sherlock
Thanks Aaron - that looks really promising. Will check it out & see if I can get it to work. On Wed, Feb 2, 2022 at 8:48 PM Aaron Ash wrote: > There's also these J bindings that can be used to read/write parquet > files directly from J: https://github.com/interregna/JArrow > > On Wed, Feb 2, 202

Re: [Jprogramming] Sierpinski triangle

2022-02-02 Thread xash
> Now why steps 10-13 result in the next row of a sierpinski triangle, I > don't know, I guess it has to do with generating a Pascal triangle. It's not that important for learning J, but it gives a hint why the seemingly confusing `72#:~8#2` was used. `bm{~3#.\row` maps three consecutive bits to b

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

2022-02-02 Thread Ric Sherlock
Thanks Stefan, Had a quick look and liked the sound of being able to work with larger-than-memory datasets by analysing streams from data sources, however wasn't so impressed by the DuckDB showing (out-of-memory) on this benchmark site https://h2oai.github.io/db-benchmark/ However it looks like the

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

2022-02-02 Thread Elijah Stone
On Wed, 2 Feb 2022, Igor Zhuravlov wrote: 1.2. Dictionary consists of keys and values. 1.2.1. A pair (key,value) is a mapping establishing structure. 1.2.2. A mapping from key to value is denoted as: {key -> value}. Ordinary j arrays permit many keys. Rather than key -> value, they ha