{"id":26997101,"url":"https://github.com/tomstuart/nothing","last_synced_at":"2025-06-22T21:05:32.132Z","repository":{"id":37821270,"uuid":"2669595","full_name":"tomstuart/nothing","owner":"tomstuart","description":"Programming with Nothing","archived":false,"fork":false,"pushed_at":"2014-01-12T12:40:49.000Z","size":162,"stargazers_count":247,"open_issues_count":2,"forks_count":21,"subscribers_count":5,"default_branch":"challenge","last_synced_at":"2025-04-04T02:03:08.964Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://tomstu.art/programming-with-nothing","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomstuart.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-29T05:55:05.000Z","updated_at":"2025-03-27T22:35:31.000Z","dependencies_parsed_at":"2022-07-14T21:46:57.206Z","dependency_job_id":null,"html_url":"https://github.com/tomstuart/nothing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tomstuart/nothing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomstuart%2Fnothing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomstuart%2Fnothing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomstuart%2Fnothing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomstuart%2Fnothing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomstuart","download_url":"https://codeload.github.com/tomstuart/nothing/tar.gz/refs/heads/challenge","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomstuart%2Fnothing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261367503,"owners_count":23147851,"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":[],"created_at":"2025-04-04T02:03:08.123Z","updated_at":"2025-06-22T21:05:27.122Z","avatar_url":"https://github.com/tomstuart.png","language":"Ruby","readme":"# Programming With Nothing\n\nThis code accompanies the [Ru3y Manor](http://rubymanor.org/3) talk “[Programming With Nothing](http://speakerdeck.com/u/tomstuart/p/programming-with-nothing)”.\n\nThe idea is to implement some basic data structures and control flow under the constraint of only being allowed to create and call procs.\n\n## Getting started\n\nAll code uses the `-\u003e` syntax, so **Ruby 1.9 is required**.\n\nIf you are brave, the `challenge` branch has a set of pending specs and an empty implementation file. Can you make them all pass without breaking any of the rules? Use `bundle install` to set up RSpec, then just type `rspec` to run the specs. (To use autotest, run `gem install ZenTest` and then `autotest`.)\n\nIf you are afraid, the `story` branch contains a series of commits which fill out the implementation until all the specs pass.\n\n## Rules\n\n* Your code may create procs (with `Proc.new`, `Kernel.proc`, `Kernel.lambda` or `-\u003e`) and call procs (with `Proc#call`, `Proc#[]`, `Proc#===` or `Proc#()`).\n* Aside from the above, you may not use any of Ruby's built-in classes, modules, methods, keywords or other language features.\n* You may not assign to local variables.\n* As a practical consideration, you must define constants in order to expose your implementations to the specs. You may also define and later refer to constants for the purpose of code reuse.\n* Constant definition may not be used to sneak recursion in through the back door. A constant is not defined until you have finished defining it, so defining `FOO` in terms of `FOO` is cheating.\n\n## Hints\n\n* `DECREMENT` is hard, so you may need to [steal `PRED`](http://en.wikipedia.org/wiki/Lambda_calculus#Arithmetic_in_lambda_calculus).\n* The evaluation of any proc-valued expression `e` can be deferred by writing it as `-\u003e x { e[x] }` as long as it doesn't have any free variables called `x`. (This is [eta-conversion](http://en.wikipedia.org/wiki/Lambda_calculus#.CE.B7-conversion).)\n* Self-application is the simplest way to define a recursive function without cheating. Instead of `FOO = ... FOO[...] ...`, try `BAR = -\u003e f { ... f[f][...] ... }; FOO = BAR[BAR]`.\n* The more complex [Y combinator](http://en.wikipedia.org/wiki/Fixed_point_combinator#Y_combinator) is a tidier way to define a recursive function, but in Ruby it loops forever; try the [Z combinator](http://en.wikipedia.org/wiki/Fixed_point_combinator#Other_fixed_point_combinators) instead.\n* If you're already familiar with functional programming, beware that operation names and argument order have been chosen to be familiar to Ruby programmers, e.g. `UNSHIFT` (vs. `CONS`) takes a list as its first (vs. last) argument. If you are upset, see the `pedant` branch.\n\n## Console\n\n```ruby\n$ irb -Ilib -Ispec -rsupport/helpers\n\n\u003e\u003e include Nothing, Helpers\n=\u003e Object\n\n\u003e\u003e to_integer(from_integer(42))\n=\u003e 42\n\n\u003e\u003e to_boolean(from_boolean(false))\n=\u003e false\n\n\u003e\u003e to_array(from_array([true, 9, :hello]))\n=\u003e [true, 9, :hello]\n\n\u003e\u003e to_array(from_array([representation_of(3), representation_of(5)])).map { |n| to_integer(n) }\n=\u003e [3, 5]\n\n\u003e\u003e to_integer(ADD[TWO][THREE])\n=\u003e 5\n```\n\n## Legal\n\nCopyright 2011 Tom Stuart (\u003ctom@experthuman.com\u003e, [@tomstuart](http://twitter.com/tomstuart)). This is free software; see COPYING for details.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomstuart%2Fnothing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomstuart%2Fnothing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomstuart%2Fnothing/lists"}