{"id":16627093,"url":"https://github.com/ttulka/i-am-selfish","last_synced_at":"2025-03-28T03:15:19.244Z","repository":{"id":243213333,"uuid":"809702332","full_name":"ttulka/i-am-selfish","owner":"ttulka","description":"esoteric programming language that solely discusses itself","archived":false,"fork":false,"pushed_at":"2024-06-08T07:31:06.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T17:04:15.841Z","etag":null,"topics":["esolang","programming-language","selfish"],"latest_commit_sha":null,"homepage":"https://esolangs.org/wiki/I_am_selfish","language":"JavaScript","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/ttulka.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":"2024-06-03T09:33:30.000Z","updated_at":"2024-06-12T12:17:42.000Z","dependencies_parsed_at":"2024-06-07T11:42:48.396Z","dependency_job_id":"435bdab3-904f-4c72-84bc-c0aaadce8201","html_url":"https://github.com/ttulka/i-am-selfish","commit_stats":null,"previous_names":["ttulka/i-am-selfish"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fi-am-selfish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fi-am-selfish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fi-am-selfish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fi-am-selfish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttulka","download_url":"https://codeload.github.com/ttulka/i-am-selfish/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245960813,"owners_count":20700781,"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":["esolang","programming-language","selfish"],"created_at":"2024-10-12T04:13:20.297Z","updated_at":"2025-03-28T03:15:19.213Z","avatar_url":"https://github.com/ttulka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# I am selfish\n\n**I am selfish** is an esoteric programming language that solely discusses itself, permitting only variations of the symbol \"*I*\":\n\n| Symbol | Encoded | Unicode name | \n| :----: | :-----: | ------------ |\n| `I`    | \\u0049  | Latin capital letter I | \n| `Ι`    | \\u0399  | Greek capital letter iota |\n| `І`    | \\u0406  | Cyrillic capital letter Byelorussian-Ukrainian I |\n| `Ӏ`    | \\u04c0  | Cyrillic letter Palochka |\n\nBased on the symbols they are denoted by, instructions operate on one of four registers:\n\n| Symbol | Encoded | Register |\n| :----: | :-----: | :------: |\n| `I`    | \\u0049  | 0        |\n| `Ι`    | \\u0399  | 1        |\n| `І`    | \\u0406  | 2        |\n| `Ӏ`    | \\u04c0  | 3        |\n\nI am selfish has four instructions: increment, decrement, selection, and jump. \nInstructions are denoted as a unary number using one of the \"I\" symbols:\n\n| Number | Instruction | Meaning | Example |\n| :----: | ----------- | ------- | ------- |\n| 1      | Increment   | Increments the register | `I` |\n| 2      | Decrement   | Decrements the register | `II` |\n| 3      | Selection   | Skips the next instruction if the register is zero | `III` |\n| ≥4    | Jump        | Jumps to an instruction | `IIII`, `IIIII`, `IIIIII`, ... |\n\nJump is unconditional; its target is determined by the number of symbols appended to the instruction. Four symbols refer to zero, five to one, six to two, and so on. It counts only instructions that use the same symbols as the jump itself.\n\nSince only \"*I*\" symbols are allowed, instructions with different symbols must be used as separators; otherwise, the code would be ambiguous.\n\nThe selection and jump instructions together provide conditional jumps sufficient for Turing completeness.\n\n## Examples\n\nTo make the code more readable, we will use the following notation (pseudocode): the \"*I*\" symbols will be replaced by *A*, *B*, *C*, *D*, and other symbols will be ignored as comments.\n\n### Empty program\n\nDoes nothing:\n\n```\n```\n\n### Infinite loop\n\nNever stops:\n\n```\nAAAA\n```\n\nor\n\n```\nIIII\n```\n\nThe instruction simply jumps to itself again and again.\n\n\n### Logic operations\n\nSome boolean operations can be done with using only increments and selections:\n\n```\nc = a and b\nAAAD BBBD A DDDC\n\nc = a or b\nAAAD BBBA DDDC AAAC\n```\n\nor\n\n```\nIIIӀΙΙΙӀIӀӀӀІ\n```\n\n```\nIIIӀΙΙΙIӀӀӀІIIIІ\n```\n\n### Addition\n\nAdd *A* and *B* (A = A + B):\n\n```\nBBB CCCCC    if b==0 jump to end\nBB           b--\nA            a++\nBBBB         jump to begin\nCC           end label\n```\n\nor\n\n```\nΙΙΙІІІІІΙΙIΙΙΙΙІІ\n```\n\n### Multiplication\n\nMultiples *A* with *B* (A = A × B):\n\n```\n@init           initially move a to c:\nAAA BBBB B      if a==0 jump @begin\nAA C            a-- c++\nAAAA            jump @init\n\n@begin          add c to a via d b-times:\nBBB CCCC CCCCCC if b==0 jump @end\nBB              b--\n@add\nCCC DDDD DD     jump @mv\nCC A D          c-- a++ d++\nCCCC CC         jump @add\n@mv             move d back to c:\nDDD BBBBB       if d==0 jump @begin\nDD C            d-- c++\nDDDD DD         jump @mv          \n@end CC         just label \n```\n\nor\n\n```\nIIIΙΙΙΙΙIIІIIIIΙΙΙІІІІІІІІІІΙΙІІІӀӀӀӀӀӀІІIӀІІІІІІӀӀӀΙΙΙΙΙӀӀІӀӀӀӀӀӀІІ\n```\n\n### Fibonacci sequence\n\nComputes the Fibonacci sequence starting with the elements in *A* and *B*, continuing until the number of elements specified in *C*:\n\n```\n@begin\nCCC DDDD DDDDDD  if c==0 jump to @end\nCC               c--\n\n@b2d             move b to d\nBBB AAAA A       if b==0 jump to @a2b\nBB D             b-- d++\nBBBB             jump to @b2d\n\n@a2b             move a to b\nAAA DDDD DDD     if a==0 jump to @d2ab\nAA B             a-- b++\nAAAA A           jump to @a2b\n\n@d2ab            move d to a and b\nDDD CCCC         if d==0 jump to @begin\nDD A B           d-- a++ b++\nDDDD DD          jump to @d2ab\n\n@end CC DD       label; both are noop\n```\n\nor\n\n```\nІІІӀӀӀӀӀӀӀӀӀӀІІΙΙΙIIIIIΙΙӀΙΙΙΙIIIӀӀӀӀӀӀӀIIΙIIIIIӀӀӀІІІІӀӀIΙӀӀӀӀӀӀІІӀӀ\n```\n\n### Hello World\n\nFor computing \"Hello World\" the numbers in the registers must be interpreted as letters. \n  It can achieved by defining a simple alphabet:\n\n| Letter | Value |\n| :----: | :---: |\n| ` `    | 1     |\n| `d`    | 2     |\n| `e`    | 3     |\n| `H`    | 4     |\n| `l`    | 5     |\n| `o`    | 6     |\n| `r`    | 7     |\n| `W`    | 8     |\n\nThe following program sets *A* progressively to 4, 3, 5, 5, 6, 1, 8, 6, 7, 5, 2\n  which corresponds to \"Hello World\":\n\n```\nABBABBABBABB              H\nAABBAABBAABBAABB\nABBABBABB                 e\nAABBAABBAABB\nABBABBABBABBABB           l\nAABBAABBAABBAABBAABB\nABBABBABBABBABB           l\nAABBAABBAABBAABBAABB\nABBABBABBABBABBABB        o\nAABBAABBAABBAABBAABBAABB\nABB                       _\nAABB\nABBABBABBABBABBABBABBABB  W\nAABBAABBAABBAABBAABBAABBAABBAABB\nABBABBABBABBABBABB        o\nAABBAABBAABBAABBAABBAABB\nABBABBABBABBABBABBABB     r\nAABBAABBAABBAABBAABBAABBAABB\nABBABBABBABBABB           l\nAABBAABBAABBAABBAABB\nABBABB                    d\nAABBAA\n```\n\nor (newlines are added arbitrarily)\n\n```\nIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙ\nIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙ\nIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙ\nIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙII\nΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙII\nΙΙIIΙΙIIΙΙIΙΙIΙΙIΙΙIΙΙIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIIΙΙIΙΙIΙΙIIΙΙII\n```\n\n## JavaScript interpreter\n\n```sh\nnpm i i-am-selfish\n```\n\n```js\nconst selfish = require('i-am-selfish')\n\nconst result = selfish(\n    'ΙΙΙІІІІІΙΙIΙΙΙΙІІ', \n    [42, 13]\n)\nresult[0]  // 55\n```\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fi-am-selfish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttulka%2Fi-am-selfish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fi-am-selfish/lists"}