| Name | jjinx JSON |
| Version |
0.0.1
JSON |
| download |
| home_page | None |
| Summary | Interpreter for the J programming language. |
| upload_time | 2025-10-12 13:21:19 |
| maintainer | None |
| docs_url | None |
| author | Alex Riley |
| requires_python | >=3.13 |
| license | MIT License Copyright (c) 2025 Alex Riley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| keywords |
j
interpreter
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Jinx

An experimental interpreter for the J programming language, built on top of [NumPy](https://numpy.org/).
Implements many of J's primitives and tacit programming capabilities, and can be extended to support execution via other frameworks too.
## Executing J
Start the interactive shell:
```sh
jinx
```
The shell prompt is four spaces, so commands appear indented. Internally, all multidimensional arrays are NumPy arrays. Verbs, conjunctions and adverbs are a mixture of Python and NumPy methods.
Here are some examples what Jinx can do so far:
- Solve the "trapping rainwater" problem (solution taken from [here](https://mmapped.blog/posts/04-square-joy-trapped-rain-water)):
```j
+/@((>./\ <. >./\.)-]) 0 1 0 2 1 0 1 3 2 1 2 1
6
```
- Compute the correlation between two arrays of numbers (taken from [here](https://stackoverflow.com/a/44845495/3923281)). This is a complex combination of different verbs, adverbs, conjunctions and trains:
```j
2 1 1 7 9 (+/@:* % *&(+/)&.:*:)&(- +/%#) 6 3 1 5 7
0.721332
```
- Create identity matrices in inventive ways (see [this essay](https://code.jsoftware.com/wiki/Essays/Identity_Matrix)):
```j
|.@~:\ @ ($&0) 3
1 0 0
0 1 0
0 0 1
(i.@,~ = >: * i.) 3
1 0 0
0 1 0
0 0 1
((={:)\ @ i.) 3
1 0 0
0 1 0
0 0 1
```
- Solve the Josephus problem (see [this essay](https://code.jsoftware.com/wiki/Essays/Josephus_Problem)). Calculate the survivor's number for a circle of people of size N. Note the use of verb obverse and the rank conjunction:
```j
(1&|.&.#:)"0 >: i. 5 10 NB. N ranges from 1 to 50 here (arranged as a table)
1 1 3 1 3 5 7 1 3 5
7 9 11 13 15 1 3 5 7 9
11 13 15 17 19 21 23 25 27 29
31 1 3 5 7 9 11 13 15 17
19 21 23 25 27 29 31 33 35 37
```
- Build nested boxes containing heterogeneous data types and print the contents:
```j
(<<'abc'),(<(<'de',.'fg'),(<<i. 5 2)),(<(<"0 ] % i. 2 2 3))
┌─────┬──────────┬────────────────────────────┐
│┌───┐│┌──┬─────┐│┌────────┬────────┬────────┐│
││abc│││df│┌───┐│││_ │1 │0.5 ││
│└───┘││eg││0 1│││├────────┼────────┼────────┤│
│ ││ ││2 3││││0.333333│0.25 │0.2 ││
│ ││ ││4 5│││└────────┴────────┴────────┘│
│ ││ ││6 7│││ │
│ ││ ││8 9│││┌────────┬────────┬────────┐│
│ ││ │└───┘│││0.166667│0.142857│0.125 ││
│ │└──┴─────┘│├────────┼────────┼────────┤│
│ │ ││0.111111│0.1 │0.090909││
│ │ │└────────┴────────┴────────┘│
└─────┴──────────┴────────────────────────────┘
```
## Easily Customisable
Everything is in Python. Adding new primitives is easy.
Update the `primitives.py` file with your new part of speech (e.g. a new verb such as `+::`). Write your implementation of this new part of speech in the relevant executor module (e.g. `verbs.py`) and then update the name-to-method mapping at the foot of that module. That's all that's needed.
## Alternative Executors
Execution of sentences is backed by NumPy by default.
However Jinx is designed so that it's possible to implement the primitives using alternative frameworks too. Python many Machine Learning and Scientific Programming libraries that could be used to execution J code.
To prove this concept, there's _highly experimental and incomplete_ support for [JAX](https://docs.jax.dev/en/latest/index.html):
```sh
jinx --executor jax
```
Primitive verbs are JIT compiled and execute on JAX arrays:
```j
mean =: +/ % #
mean 33 55 77 100 101
73.2
```
## Warning
This project is experimental. There will be bugs, missing features and performance quirks.
Many key parts of J are not currently implemented (but might be in future). These include:
- Differences in how names are interpreted and resolved at execution time.
- Locales.
- Definitions and direct definitions (using `{{ ... }}`).
- Array types other than floats, integers and and strings.
- Executing J scripts.
- Control words.
Raw data
{
"_id": null,
"home_page": null,
"name": "jjinx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.13",
"maintainer_email": null,
"keywords": "J, interpreter",
"author": "Alex Riley",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/cf/07/261fe7bb7f3e7c632851291136ab53dd945c48355d06246cbc59595fb3e1/jjinx-0.0.1.tar.gz",
"platform": null,
"description": "# Jinx\n\n\n\nAn experimental interpreter for the J programming language, built on top of [NumPy](https://numpy.org/).\n\nImplements many of J's primitives and tacit programming capabilities, and can be extended to support execution via other frameworks too.\n\n## Executing J\n\nStart the interactive shell:\n```sh\njinx\n```\nThe shell prompt is four spaces, so commands appear indented. Internally, all multidimensional arrays are NumPy arrays. Verbs, conjunctions and adverbs are a mixture of Python and NumPy methods.\n\nHere are some examples what Jinx can do so far:\n\n- Solve the \"trapping rainwater\" problem (solution taken from [here](https://mmapped.blog/posts/04-square-joy-trapped-rain-water)):\n```j\n +/@((>./\\ <. >./\\.)-]) 0 1 0 2 1 0 1 3 2 1 2 1\n6\n```\n- Compute the correlation between two arrays of numbers (taken from [here](https://stackoverflow.com/a/44845495/3923281)). This is a complex combination of different verbs, adverbs, conjunctions and trains:\n```j\n 2 1 1 7 9 (+/@:* % *&(+/)&.:*:)&(- +/%#) 6 3 1 5 7\n0.721332\n```\n- Create identity matrices in inventive ways (see [this essay](https://code.jsoftware.com/wiki/Essays/Identity_Matrix)):\n```j\n |.@~:\\ @ ($&0) 3\n1 0 0\n0 1 0\n0 0 1\n\n (i.@,~ = >: * i.) 3\n1 0 0\n0 1 0\n0 0 1\n\n ((={:)\\ @ i.) 3\n1 0 0\n0 1 0\n0 0 1\n```\n- Solve the Josephus problem (see [this essay](https://code.jsoftware.com/wiki/Essays/Josephus_Problem)). Calculate the survivor's number for a circle of people of size N. Note the use of verb obverse and the rank conjunction:\n```j\n (1&|.&.#:)\"0 >: i. 5 10 NB. N ranges from 1 to 50 here (arranged as a table)\n 1 1 3 1 3 5 7 1 3 5\n 7 9 11 13 15 1 3 5 7 9\n11 13 15 17 19 21 23 25 27 29\n31 1 3 5 7 9 11 13 15 17\n19 21 23 25 27 29 31 33 35 37\n```\n- Build nested boxes containing heterogeneous data types and print the contents:\n```j\n (<<'abc'),(<(<'de',.'fg'),(<<i. 5 2)),(<(<\"0 ] % i. 2 2 3))\n\u250c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502\u250c\u2500\u2500\u2500\u2510\u2502\u250c\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2510\u2502\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2502\n\u2502\u2502abc\u2502\u2502\u2502df\u2502\u250c\u2500\u2500\u2500\u2510\u2502\u2502\u2502_ \u25021 \u25020.5 \u2502\u2502\n\u2502\u2514\u2500\u2500\u2500\u2518\u2502\u2502eg\u2502\u25020 1\u2502\u2502\u2502\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\u2502\n\u2502 \u2502\u2502 \u2502\u25022 3\u2502\u2502\u2502\u25020.333333\u25020.25 \u25020.2 \u2502\u2502\n\u2502 \u2502\u2502 \u2502\u25024 5\u2502\u2502\u2502\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2502\n\u2502 \u2502\u2502 \u2502\u25026 7\u2502\u2502\u2502 \u2502\n\u2502 \u2502\u2502 \u2502\u25028 9\u2502\u2502\u2502\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u2502\n\u2502 \u2502\u2502 \u2502\u2514\u2500\u2500\u2500\u2518\u2502\u2502\u25020.166667\u25020.142857\u25020.125 \u2502\u2502\n\u2502 \u2502\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2518\u2502\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\u2502\n\u2502 \u2502 \u2502\u25020.111111\u25020.1 \u25020.090909\u2502\u2502\n\u2502 \u2502 \u2502\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n## Easily Customisable\n\nEverything is in Python. Adding new primitives is easy.\n\nUpdate the `primitives.py` file with your new part of speech (e.g. a new verb such as `+::`). Write your implementation of this new part of speech in the relevant executor module (e.g. `verbs.py`) and then update the name-to-method mapping at the foot of that module. That's all that's needed.\n\n## Alternative Executors\n\nExecution of sentences is backed by NumPy by default.\n\nHowever Jinx is designed so that it's possible to implement the primitives using alternative frameworks too. Python many Machine Learning and Scientific Programming libraries that could be used to execution J code.\n\nTo prove this concept, there's _highly experimental and incomplete_ support for [JAX](https://docs.jax.dev/en/latest/index.html):\n```sh\njinx --executor jax\n```\nPrimitive verbs are JIT compiled and execute on JAX arrays:\n```j\n mean =: +/ % #\n mean 33 55 77 100 101\n73.2\n```\n\n## Warning\n\nThis project is experimental. There will be bugs, missing features and performance quirks.\n\nMany key parts of J are not currently implemented (but might be in future). These include:\n- Differences in how names are interpreted and resolved at execution time.\n- Locales.\n- Definitions and direct definitions (using `{{ ... }}`).\n- Array types other than floats, integers and and strings.\n- Executing J scripts.\n- Control words.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2025 Alex Riley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Interpreter for the J programming language.",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/ajcr/jinx"
},
"split_keywords": [
"j",
" interpreter"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b625384b0deac93cc522e18a61d5b2c20cf03baad20840d2288988aefe502d2c",
"md5": "09185ecdffea475e68172420d63c45ed",
"sha256": "1bfd32039d55dbab6d0e73a55d4bdacb560a735ed3af5990b0eb1df032598c3c"
},
"downloads": -1,
"filename": "jjinx-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "09185ecdffea475e68172420d63c45ed",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.13",
"size": 44054,
"upload_time": "2025-10-12T13:21:18",
"upload_time_iso_8601": "2025-10-12T13:21:18.687513Z",
"url": "https://files.pythonhosted.org/packages/b6/25/384b0deac93cc522e18a61d5b2c20cf03baad20840d2288988aefe502d2c/jjinx-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cf07261fe7bb7f3e7c632851291136ab53dd945c48355d06246cbc59595fb3e1",
"md5": "6ebd610f1390420e8cf3273d6eef01fc",
"sha256": "fad5e41aecdfc18fd215e80d42542d598d56ba55ed8151d61ab308419519932e"
},
"downloads": -1,
"filename": "jjinx-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6ebd610f1390420e8cf3273d6eef01fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.13",
"size": 41705,
"upload_time": "2025-10-12T13:21:19",
"upload_time_iso_8601": "2025-10-12T13:21:19.839473Z",
"url": "https://files.pythonhosted.org/packages/cf/07/261fe7bb7f3e7c632851291136ab53dd945c48355d06246cbc59595fb3e1/jjinx-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-12 13:21:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ajcr",
"github_project": "jinx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jjinx"
}