-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw4.hoon
96 lines (74 loc) · 2.5 KB
/
hw4.hoon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
:: Q1
%- list @ud
(list @ud)
::Q2
^- %- list @ud [1 2 3 4 5 ~]
::Q3
`(list @ud)`[1 2 3 4 5 ~]
::Q4
=/ animal $? %snake %lizard %bird %dog %cat ==
^- (list animal) [%snake %lizard %bird ~]
::Q5
=/ carlist ^- (list @t) ['toyota' 'ford' 'chevy' ~]
^- (list @t) :- 'bentley' carlist
::Q6
=/ carlist ^- (list @t) ['toyota' 'ford' 'chevy' ~]
^- (list @t) ['bentley' carlist]
::Q7
=/ starlist `(list @p)`[~sonnet ~winter ~diglet ~ponnys ~]
?~ starlist !!
i.starlist
::Alternatively, code below also works
=/ starlist `(lest @p)`[~sonnet ~winter ~diglet ~ponnys ~]
i.starlist
::Q8
=/ starlist `(lest @p)`[~sonnet ~winter ~diglet ~ponnys ~]
t.starlist
::Q9
%+ gulf 1 50
::Q10
=/ mul2 |=(a=@ud (mul a 2))
%+ turn %+ gulf 1 50 mul2
::Q11
=/ mul2 |=(a=@ud (mul a 2))
%+ roll %+ turn %+ gulf 1 50 mul2 add
::Q12
=/ is-star |=(p=@p &((gth p 255) (lth p 65.536)))
%+ skim `(list @p)`[~zod ~binrul ~sampel-palnet ~mister-rabbyt ~litzod ~sonnet ~nec ~wes ~] is-star
::Q13
=/ is-star |=(p=@p &((gth p 255) (lth p 65.536)))
%- lent %+ skim `(list @p)`[~zod ~binrul ~sampel-palnet ~mister-rabbyt ~litzod ~sonnet ~nec ~wes ~] is-star
::Q14
((sane %t) 'see you on mars!')
((sane %ta) ~.spaceship)
((sane %tas) ~.spaceship)
((sane %ta) %rocket-123)
((sane %tas) %rocket-123)
::Q15
((sane %t) 'abcd-1234')
((sane %ta) 'abcd-1234')
((sane %tas) 'abcd-1234')
^- (list @tD) "abcd-1234"
::Q16
((sane %t) 'Thë ångström įs ä vęry smäll ûnīt øf méäśürèmęnt')
((sane %ta) 'Thë ångström įs ä vęry smäll ûnīt øf méäśürèmęnt')
((sane %tas) 'Thë ångström įs ä vęry smäll ûnīt øf méäśürèmęnt')
^- (list @tD) "Thë ångström įs ä vęry smäll ûnīt øf méäśürèmęnt"
::Q17
^- %- list @tD ~[`@`114 `@`97 `@`105 `@`110 `@`98 `@`111 `@`119 `@`32 `@`115 `@`104 `@`101 `@`114 `@`98 `@`101 `@`116]
::Q18
^- tape ~[`@`114 `@`97 `@`105 `@`110 `@`98 `@`111 `@`119 `@`32 `@`115 `@`104 `@`101 `@`114 `@`98 `@`101 `@`116]
::Q19
^- tape ^- (list @) ~[114 97 105 110 98 111 119 32 115 104 101 114 98 101 116]
::Q20
%+ weld %- flop " liah lla" %- flop %- cuss "urbit"
::Q21
%^ snap "I have a lot of honey" 16 'm'
::Q22
%- crip %^ snap "I have a lot of honey" 16 'm'
::You can also try then passing it to trip (tape rip) to convert it back to a tape.
%- trip %- crip %^ snap "I have a lot of honey" 16 'm'
::Q23
=/ ship ^- @p ~tamlut-modnys
=/ num ^- @ud 24
"Hello, I'm {<ship>} and I like the number {<num>}."