Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
NuVoc: J Vocabulary (jsoftware.com)
18 points by agarttha on June 13, 2014 | hide | past | favorite | 6 comments



I have been wondering if there are dialects of J that sacrifice brevity but retain the computational model. I do not know J but the way I understand it, it would be rather easy to develop two-way translation.


You can do this in J; nobody does. It would probably be more approachable to many people to write:

    mean =: sum reduce div size
Than:

    mean =: +/ % #
But less of your program fits on the screen at once, so you don’t have as broad a view. Then again, people who haven’t used an APL dialect won’t know what they’re missing anyway.


Whence this assumption that filling your entire screen with characters is helpful for understanding your program?


These operators are like the word "whence": a denser notation that could just as easily be written out in full, in a way more friendly to non-experts in the language - for example, as "from where" - but if you're already an expert thinking in terms of these dense operators, why not write that way? It's only natural.


This is wonderful. I remember using http://www.jsoftware.com/help/dictionary/vocabul.htm some time ago and you would often have to study an entry for a long time to make {. or {: of it.


J manuals (J for C, I think) mention that in J array is a central object, so when you have primitive operations you have more of them, because an array allows you to do more things than a scalar.

There is a set of more frequently used operations, and there are others, which provide convenient shortcuts in some cases or are useful in some relatively narrow areas. Basic operations with arrays are: {. - take the first item, {: - take the last item, }. - take everything except the first item, }: - take everything except the last item. Then there is "generalized" sorting operation /: - ascending and \: - descending, array reversal |. , you can take unique elements of array with ~. , subtract one array from another with -: and apply dyadic operation between elements of an array with / - for example, +/ 1 2 3 makes 6. You can append arrays with , - for example, 1 2 , 3 4 makes 1 2 3 4. You can "zip" arrays with ,. - 1 2 3 ,. 4 5 6 makes array of pairs 1 4, 2 5 and 3 6. Then you also have several built-in ways to partition array - using first or last element of array as separator with ;. , making prefixes or suffixes of increasing length with \ or \. , you can group elements of one array by elements of another using /. - for example, 1 1 2 3 3 4 /. 'abcdef' will produce groups ab, c, de, f . Then there is ability to combine array items with weights using #. - like, 2 hours 3 minutes and 4 seconds total 24 60 60 #. 2 3 4 -> 7384 seconds - and do that backwards with #: , get array length or filter array elements with # , get cartesian product with { ... and that's about it. Pretty powerful, well thought-out set of highly orthogonal operations. Add scalar operations - where complex numbers and arbitrary precision are built-in - and you have a good base for a universal language.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: