-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4e363a8
Showing
16 changed files
with
5,455 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
.urbitrc | ||
zod | ||
urbit | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Jose L. Bellod Cisneros | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Hoon School | ||
|
||
# Hoon 101 | ||
|
||
`%/hoon101` | ||
|
||
Copy all files inside the `%/gen` folder and `|commit %base` manually. | ||
|
||
# Hoon 201 | ||
`%/hoon201` | ||
## Using | ||
|
||
First you need to create a file called `.urbitrc` | ||
|
||
``` | ||
module.exports = { | ||
URBIT_PIERS: [ | ||
"<PATH_TO_YOUR_URBIT>/base", | ||
] | ||
}; | ||
``` | ||
|
||
`npm run serve` | ||
|
||
Watches the assignment folder located in `%/hoon201/assignments` and syncs all files it into your Urbit ship's folder. | ||
|
||
After the files have been copied or modifed, run `|commit %base` to sync them with clay. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
:: week1 | ||
:: | ||
:: Build a naked generator that takes an atom from the user and returns | ||
:: that atom with a different aura. | ||
:: | ||
:: First mention what a naked generator is here, with a link to the docs. | ||
:: | ||
:: [Naked generator](https://deploy-preview-133--urbit-org.netlify.com/docs/learn/hoon/hoon-tutorial/generators/) | ||
:: | ||
:: | ||
:: | ||
/? 310 | ||
:: | ||
|= a=@ | ||
^- @p | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:: week2 | ||
:: | ||
:: Build a naked generator that takes a noun and checks if that noun is a cell | ||
:: or an atom. If that input noun is an atom, check if it’s even or odd. | ||
:: | ||
:: The output should be of the tape type. A tape is a string. | ||
:: | ||
/? 310 | ||
:: | ||
|= a=^ | ||
?^ "cell" | ||
?: (= (mod a 2) 0) | ||
"even atom" | ||
"uneven atom" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
:: week3 | ||
:: | ||
:: 1. Comment each line of code from the tail-call optimized recursion example | ||
:: to explain what the code is doing. | ||
:: | ||
:: 2. Build a naked generator that accepts a list as its argument, and returns | ||
:: the third element of that list. Do not use any standard-library functions. | ||
:: | ||
:: Lists are kinds of nouns that are written as [1 2 3 4 ~]. | ||
:: | ||
/? 310 | ||
:: | ||
:: a faster way would be to just return: | ||
:: &3:a | ||
:: | ||
|= a=(list *) | ||
=+ i=2 | ||
|- | ||
?~ a ~ | ||
?: =(i 0) i.a | ||
$(i (dec i), a t.a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
:: week4 | ||
:: | ||
:: If we list all the natural numbers below 10 that are multiples of 3 or 5, | ||
:: we get 3, 5, 6 and 9. The sum of these multiples is 23. | ||
:: | ||
:: Find the sum of all the multiples of 3 or 5 below 1000. | ||
:: | ||
:: | ||
/? 310 | ||
:: | ||
=> |% | ||
++ multiple-3-5 | ||
|= a=@ ^- ? | ||
|(=((mod a 3) 0) =((mod a 5) 0)) | ||
-- | ||
:: | ||
|= x=* | ||
^- @ | ||
=| count=@ | ||
=| sum=@ | ||
|- ^- @ | ||
?: =(count 1.000) sum | ||
%= $ | ||
sum ?:((multiple-3-5 count) (add sum count) sum) | ||
count +(count) | ||
== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
:: week5 | ||
:: | ||
:: Here is a generator that checks for counterexamples of the unproven Goldbach | ||
:: conjecture, up to a certain number. | ||
|
||
:: 1. Add comments to each line to explain what the code is doing. | ||
:: | ||
:: 2. Here is the skeleton of a naked generator. Complete it so that it’s that | ||
:: takes a tape as an argument and produces a tape as it’s output which is a | ||
:: translation of the input tape into Morse Code. | ||
:: | ||
/? 310 | ||
:: | ||
|= raw=tape | ||
=< | ||
|- ^- tape | ||
?~ raw ~ | ||
[(convert i.raw) $(raw t.raw)] | ||
|% | ||
++ convert | ||
|= a=@t | ||
^- @t | ||
:: (~(got by a) b) produces the value located at key b within map a | ||
=/ chart (~(got by table) a) | ||
chart | ||
:: | ||
++ table | ||
%- my | ||
:~ :- 'A' '.-' | ||
:- 'B' '-...' | ||
:- 'C' '-.-.' | ||
:- 'D' '-..' | ||
:- 'E' '.' | ||
:- 'F' '..-.' | ||
:- 'G' '--.' | ||
:- 'H' '....' | ||
:- 'I' '..' | ||
:- 'J' '.---' | ||
:- 'K' '-.-' | ||
:- 'L' '.-..' | ||
:- 'M' '--' | ||
:- 'N' '-.' | ||
:- 'O' '---' | ||
:- 'P' '.--.' | ||
:- 'Q' '--.-' | ||
:- 'R' '.-.' | ||
:- 'S' '...' | ||
:- 'T' '-' | ||
:- 'U' '..-' | ||
:- 'V' '...-' | ||
:- 'W' '.--' | ||
:- 'X' '-..-' | ||
:- 'Y' '-.--' | ||
:- 'Z' '--..' | ||
:- '0' '-----' | ||
:- '1' '.----' | ||
:- '2' '..---' | ||
:- '3' '...--' | ||
:- '4' '....-' | ||
:- '5' '.....' | ||
:- '6' '-....' | ||
:- '7' '--...' | ||
:- '8' '---..' | ||
:- '9' '----.' | ||
== | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
:: week6 | ||
:: | ||
:: Write a %say generator that takes two arguments x and y and produces a list | ||
:: of x lists of y cards from a standard 52 card deck | ||
:: | ||
/? 310 | ||
:: | ||
:- %say | ||
|= [[* eny=@ *] [x=@ y=@ ~] ~] | ||
=< :: %baraja is pushed in the subject & innitialized/shuffled | ||
:: | ||
=/ baraja barajar:baraja | ||
:- %noun | ||
|- ^- (list (list carta)) | ||
?: =(0 x) ~ | ||
=^ hand baraja (repartir:baraja y) | ||
[hand $(x (dec x))] | ||
:: | ||
=> |% | ||
+| %types | ||
+$ palo $? %oros %copas %espadas %bastos | ||
== | ||
:: | ||
+$ naipe $? %as %dos %tres %cuatro %cinco %seis | ||
%siete %ocho %nueve %sota %caballo %rey | ||
== | ||
:: | ||
+$ carta [=palo =naipe] | ||
-- | ||
:: | ||
|% | ||
+| %engine | ||
++ baraja | ||
|_ [cartas=(list carta)] | ||
++ this . | ||
++ palos ~[%copas %espadas %bastos %oros] | ||
++ naipes :~ %as %dos %tres %cuatro %cinco %seis | ||
%siete %ocho %nueve %sota %caballo %rey | ||
== | ||
:: | ||
:: (naive) innitializer of the %cartas of %baraja (i.e. deck) | ||
:: | ||
++ init | ||
=| cartos=(list carta) | ||
=/ p=(list palo) palos | ||
|- ^- (list carta) | ||
?~ p | ||
cartos | ||
=/ n=(list naipe) naipes | ||
|- ^- (list carta) | ||
?~ n | ||
^$(p t.p) | ||
[[i.p i.n] $(n t.n)] | ||
:: | ||
:: %barajar: randomizes the deck of cards (i.e. shuffle) | ||
:: | ||
++ barajar | ||
^- _this | ||
:: TODO: Randomize the deck | ||
:: | ||
this(cartas init) | ||
:: | ||
:: %repartir: hands out %num cards. | ||
:: updates %cartas samples removing the %naipes that have been handed out. | ||
:: | ||
++ repartir | ||
|= num=@ | ||
^- (quip carta _this) | ||
=| hand=(list carta) | ||
|- | ||
?~ cartas [hand this] | ||
?: =(num 0) [hand this] | ||
%= $ | ||
hand [i.cartas hand] | ||
cartas t.cartas | ||
num (dec num) | ||
== | ||
-- | ||
-- |
Binary file not shown.
Oops, something went wrong.