{"id":23194724,"url":"https://github.com/abrudz/stencil","last_synced_at":"2026-02-02T07:04:30.259Z","repository":{"id":90728876,"uuid":"111903897","full_name":"abrudz/Stencil","owner":"abrudz","description":"Thin cover for Dyalog APL's ⌺","archived":false,"fork":false,"pushed_at":"2018-06-20T17:48:54.000Z","size":22,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T07:43:18.394Z","etag":null,"topics":["apl","cellular-automata","cellular-automaton","code-golf","codegolf","dyalog-apl","dyalog-library","dyalogapl","game-of-life","gameoflife","moore-neighborhoods","neighbourhood","stencil","tio"],"latest_commit_sha":null,"homepage":null,"language":"APL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abrudz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-24T10:04:50.000Z","updated_at":"2025-01-10T15:17:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"9154a7b4-1d62-4dc2-9c45-a66c433f2367","html_url":"https://github.com/abrudz/Stencil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abrudz/Stencil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrudz%2FStencil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrudz%2FStencil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrudz%2FStencil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrudz%2FStencil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abrudz","download_url":"https://codeload.github.com/abrudz/Stencil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abrudz%2FStencil/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262731669,"owners_count":23355394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apl","cellular-automata","cellular-automaton","code-golf","codegolf","dyalog-apl","dyalog-library","dyalogapl","game-of-life","gameoflife","moore-neighborhoods","neighbourhood","stencil","tio"],"created_at":"2024-12-18T13:15:21.064Z","updated_at":"2026-02-02T07:04:25.230Z","avatar_url":"https://github.com/abrudz.png","language":"APL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stencil\n\n## Introduction\nStencil is a thin cover for [Dyalog APL](https://www.dyalog.com/)'s ⌺ [Stencil operator](http://help.dyalog.com/16.0/Content/Language/Primitive%20Operators/Stencil.htm) and is intended as golfing language and an easy interface for common tasks involving `⌺`. Stencil code can in fact easily be rewritten as normal Dyalog APL code.\n\nFeel free to contact me, [Adám](https://stackexchange.com/users/3114363/ad%C3%A1m), in Stack Exchange's [APL chat room](https://chat.stackexchange.com/rooms/52405/apl) to learn more about Stencil and Dyalog APL.\n\n## In-APL Usage\n\nExecute `2⎕FIX'file://path/Stencil.dyalog` to load the operator.\n\nThe syntax is `result←opts (code Stencil specs) input`, but `opts` is optional.\n\nFor the specifics of [`opts`](https://github.com/abrudz/Stencil/blob/master/README.md#command-line-options), [`code`](https://github.com/abrudz/Stencil/blob/master/README.md#code), and [`specs`](https://github.com/abrudz/Stencil/blob/master/README.md#arguments), see the linked guidance for the corresponding TIO fields.\n\nInput is an array specifying the initial state.\n\n| `opts` | `result` |\n| :---: | --- |\n| none | final state or last state before going to a previously encountered state |\n| `∊` | vector of states |\n| `≢` | scalar non-negative integer |\n| `≡` | 0-by-0 numeric matrix |\n| number | a state |\n\nIf code is a function, then identifiers may be both single- and multi-letter, and spaces are needed to separate them, i.e. `me` is *not* equivalent to `m e`, and `⎕IO` is *not* set to `0` either. However, the predefined values listed [`below`](https://github.com/abrudz/Stencil/blob/master/README.md#code) *are* available.\n\n## TIO User guide\n\n[Try It Online](https://tio.run/#home) is a code testing website for many programming languages, both practical and recreational ones, made by Stack Exchange user [Dennis](https://codegolf.stackexchange.com/users/12012). The following describes the relevant fields when using [Stencil on TIO](https://tio.run/#stencil). \n\n### Command-line options\nThis may be any one of the following options:\n\n| opt | Effect |\n| :---: | --- |\n| none | return final state or last state before going to a previously encountered state |\n| `∊` | return list of states from input to final state or last state before going to a previously encountered state |\n| `≢` | return the number of states in the above |\n| `≡` | output states until stable, or forever if cyclic |\n| number | return the state after that many states |\n\ncombined with any of the following options:\n\n| opt | Effect |\n| :---: | --- |\n| `P` | `┌───┐` Plane:\u003cbr\u003e `│   │` left and right disconnected\u003cbr\u003e `└───┘` lower and upper disconnected |\n| `C` | `┌───┐` Cylinder:\u003cbr\u003e `↑   ↑` left and right joined\u003cbr\u003e `└───┘` lower and upper disconnected |\n| `T` | `┌─→─┐` Torus:\u003cbr\u003e `↑   ↑` left and right joined\u003cbr\u003e `└─→─┘` lower and upper joined |\n| `M` | `┌─→─┐` Möbius strip:\u003cbr\u003e `│   │` left and right disconnected\u003cbr\u003e `└─←─┘` lower and upper twist-joined |\n| `K` | `┌─→─┐` Klein bottle:\u003cbr\u003e `↑   ↑` left and right joined\u003cbr\u003e `└─←─┘` lower and upper twist-joined |\n| `R` | `┌─→─┐` Real projective plane:\u003cbr\u003e `↑   ↓` left and right twist-joined\u003cbr\u003e `└─←─┘` lower and upper twist-joined |\n| `I` | `┌   ┐` Infinite:\u003cbr\u003e `     ` left and right expand and shrink as needed\u003cbr\u003e `└   ┘` lower and upper expand and shrink as needed |\n\n### Code\nThis describes what shall be returned for each neighbourhood. It may be a function, or one or more character vectors.\n\nIf a single character vector, then this forms the body (i.e. without outer curly braces) of a dfn left operand to \n`⌺`. For more information about the `⌺` operator, see [its documentation](http://help.dyalog.com/16.0/Content/Language/Primitive%20Operators/Stencil.htm).\n\nIf two character vectors, then the first will be used as a dfn snippet (\u003ccode\u003e ⍵\u003c/code\u003e is appended to its right) to post-process the result(s).\n\nIf three or more character vectors, then the last will additionally be used as a dfn snippet (\u003ccode\u003e ⍵\u003c/code\u003e is appended to its right) to pre-process the input(s).\n\nStencil provides some shortcuts not available to with the original `⌺`.  All identifiers are expected to be single-letter, and no spaces are needed to separate them, i.e. `me` is equivalent to `m e`. The following values are pre-defined:\n\nNote that all code runs with `⎕IO←0` (0-based **I**ndex **O**rigin).\n\nExamples:\n\n`3 5` will use 3-row, 5-column neighbourhoods\n\n`⍪3 3` will use neighbourhoods of size 3 in every dimension, and step size \n\n| name | Description |\n| :---: | ------- |\n| `⍵` | multi-dimensional Moore neighbourhood with self |\n| `M` | vector of Moore neighbourhood with self |\n| `m` | count of non-empty cells in the above | \n| `E` | vector of moorE neighbourhood without self | \n| `e` | count of non-empty cells in the above | \n| `V` | vector of Von neumann neighbourhood with self | \n| `v` | count of non-empty cells in the above |\n| `N` | vector of von neumanN neighbourhood without self |\n| `n` | count of non-empty cells in the above |\n| `S` | scalar self  |\n| `s` | Boolean (1 or 0) for whether above is non-empty    |\n| `P` | vector of Booleans for each dimension whether it has been padded or not  |\n| `p` | number of dimensions which have been padded |\n| `⍺` | vector of amounts of padding for each dimension |\n| `W` | original input |\n| `w` | flattened original input |\n| `Y` | preprocessed input |\n| `y` | flattened preprocessed input |\n\nIn the above table, *Moore neighbordhood* means the entire n×m neighbourhood, while *von Neumann neighbourhood* means cells orthogonal to the self.\n\n### Input\nEach line is an APL expression for an initial state. Each will be processed separately.\n \n### Arguments\nThis allows specifying the neighbourhood and step size. The arguments will be joined with spaces and executed as an APL expression to be used as right operand for `⌺`. Stencil provides two shortcuts not available to with original `⌺`. If a single size is given, it will be used for every dimension. If no size is given, size 3 will be used in every dimension.\n\nExamples:\n\n`3 5` will use 3-row, 5-column neighbourhoods\n\n`⍪5 3` will use  neighbourhoods of size 5 in every dimension with a step size of 3 in every dimension\n\n## Examples\n\n### Hello, World!\n\nCode: `S`\n\nInput `Hello, World!`\n\nEvery character will be replaced by it**S**elf.\n\n### Game of Life\n\nCode: `3∊me`\n\nA cell will be alive in the next genration if there are 3 live cells either counting itself or not.\n\nTo get just the next generation, add the command-line option `1`.\n\nTo list all generations, add the command-line options `∊`.\n\nTo calculate the period of a cyclic pattern (an [oscillator](https://en.wikipedia.org/wiki/Oscillator_(cellular_automaton)) or a [spaceship](https://en.wikipedia.org/wiki/Spaceship_(cellular_automaton)), add the command-line options `≢I`\n\nTo check whether a patter is a [still life](https://en.wikipedia.org/wiki/Still_life_(cellular_automaton)), add the command-line options `≢I` and let code be `1=` `3∊me`.\n\n### Primality checker\n\nCommand-line option: `1`\n\nCode: `~S∊1,∘.×⍨2+⍳S`\n\nInput has one or more lists of integers. For each such **S**elf, it generates the integers from 0 to **S**elf-1 (`⍳S`), adds 2 (`2+`), giving from 2 to Self+1, creates a multiplication table (`∘.×⍨`), prepends a column of ones (`1,`), and asks whether the **S**elf is a member thereof (`S∊`), and then negates that (`~`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrudz%2Fstencil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabrudz%2Fstencil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabrudz%2Fstencil/lists"}