:: Lesson 3 Workbook :: Questions 1 =/ corrected-weight 10 =/ sum 0 |- ?: (lth corrected-weight 10) sum %= $ corrected-weight (mul corrected-weight 0) sum (add sum corrected-weight) == :: not sure how to make the ++ arm thing. I need to go back over the previous lessons :: Questions 2 :: Questions 3 :: Questions 4 :: Questions 5 :: Questions 6 :: Questions 7 :: Questions 8 :: ------------------------------------------------------------ :: Notes :: ------------------------------------------------------------ :: - `^+` ketlus, for enforcing a type (like `^-` but with an example) :: - `^*` kettar, for producing an example (a bunt) :: - `$?` bucwut, for producing a type union :: - `$:` buccol, for producing a named tuple :: - `!>` zapgar, for ascertaining the type of a value :: - `|=` bartis, for creating a gate :: - `::`, for commenting on code :: - `!!` zapzap, for crashing or stubbing out incomplete branches of your Hoon expressions :: - `/+` faslus, for importing a library of code :: - `|-` barhep, for producing a trap (like a loop or repetition label) :: - `.+` dotlus, for increasing a value by one :: - `.=`, for checking equality/equivalence of two values :: - `%=` centis, for "rebooting" the current code with new values :: - `|%` barcen, for collecting many functions and values in one core :: - `++` luslus (actually a digraph, not a rune, but that's technical), for labeling a gate :: - `+$` lusbuc (ditto), for labeling a type :: - `=<` tisgar, for :: - `=>` tisgal, for :: - `~&` sigpam, for output as a debugging or messaging tool :: ------------------------------------------------------------ ::Counter =/ counter 1 :: tisfas - a value called "counter" (counts number of times the code is run) =/ sum 0 :: tisfas - a value called "sum" (the storage for the counter) |- :: barhep - is the trap or loop ?: (gth counter 5) :: wutcol - is a conditional check for the loop. Its asking: Is "counter" grater than 5? sum :: the indented "sum" represents a diveation from the main backbone and is the result of trap %= $ :: centis - reboots the code back to the barhep trap after making changes to the values by the code below it. The buc is???? counter (add counter 1) :: adds 1 to each loop through the trap sum (add sum counter) :: adding the unchanged value of "counter" to "sum" == :: tistis - is a rune terminator that tells the code what its exit condition is :: ------------------------------------------------------------ ::Counter With Outputs =/ counter 1 :: tisfas - a value called "counter" (counts number of times the code is run) =/ sum 0 :: tisfas - a value called "sum" (the storage for the counter) |- :: barhep - is the trap or loop ~& "counter:" :: sigpam - is a labler ~& > counter :: sigpam - ~& >> "sum:" :: sigpam - ~& >>> sum :: sigpam - ?: (gth counter 5) :: wutcol - sum :: %= $ :: centis - counter (add counter 1) :: sum (add sum counter)) :: == :: tistis - :: ------------------------------------------------------------ ::Counter With Outputs and Interpolation =/ counter 1 =/ sum 0 |- ~& "counter: {}" ~& "sum: {}" ?: (gth counter 5) sum %= $ counter (add counter 1) sum (add sum counter) == :: ------------------------------------------------------------ ::Factorial Genorator :: place into fact.hoon =fact |= n=@ud :: bartis - for creating a gate |- :: barhep - is the trap or loop ~& n :: ?: =(n 1) :: wutcol - is the exit condition. tis is checking for equivelency n :: %+ mul :: cenlus - is a run to apply a gate to [a b] cell sample n :: %= $ :: n (dec n) :: (sub n 1) is the same thing as (dec n) == :: tistis - is the terminator that tells the code what its exit condition is :: ------------------------------------------------------------ ::Reading Hoon =/ n 15 |- ~& n ?: =(n 1) :: .= n 1 n %+ mul n %= $ n (dec n) :: %- dec n == :: ------------------------------------------------------------ :: cores: :: [battery payload] :: limbs of a core: :: - arms = computations (marked by a ++ or +$) :: - legs = data :: |% core builder barcen :: ++ arm builder luslus |% :: barcen - a core builder ++ add-one :: luslus - an arm builder with a lable of "add-one" |= a=@ud :: bartis - gate inside the arm. This gate adds one to the value ^- @ud :: kethep - (add a 1) :: ++ sub-one :: luslus - an arm builder with a lable of "sub-one" |= a=@ud :: bartis - gate inside the arm. This gate subtracts one to the value ^- @ud :: kethep - (sub a 1) :: -- :: hephep - rune terminator ~~~ 37:08 https://www.youtube.com/watch?v=rq-SawsssC0&list=PLR4NQL5fPgqqjmCyhfFjP2F5E1nofT8zC&index=13 :: ------------------------------------------------------------ :: Shadowing Names |= n=@ud |- ~& n ?: =(n 1) n %+ mul n $(n (dec n)) :: ------------------------------------------------------------ |= n=@ud ?: =(n 1) 1 (mul n $(n (dec n)))