Skip to content

Instantly share code, notes, and snippets.

View tacryt-socryp's full-sized avatar
🌊

tacryt-socryp tacryt-socryp

🌊
View GitHub Profile
@tacryt-socryp
tacryt-socryp / synapse.hoon
Last active August 2, 2019 22:51
Synapse library
|%
::
:: +permission: main permission model
::
+$ permission
$% [%white (set @p)]
[%black (set @p)]
==
::
:: +channel: main abstraction for a message bus
@tacryt-socryp
tacryt-socryp / index.html
Last active January 21, 2019 23:25
Pareto
<html>
<head>
<title>Pareto Experiment</title>
<script type="text/javascript" src="pareto.js"></script>
</head>
<body>
</body>
</html>
@tacryt-socryp
tacryt-socryp / newlist.hoon
Created June 9, 2018 00:40
Create a list of atoms from x to y (without using the Hoon stdlib for lists)
|%
++ newlist {what/@ next/(unit newlist)}
--
|= [x=@ y=@ z=(unit newlist)]
^- (unit newlist)
?~ z
?: (lte x y)
$(x x, y (dec y), z [~ [what=y next=~]])
~
?: (lte x y)
var fetch = require('node-fetch');
function authenticate(code, success) {
fetch(`http://localhost:8080/~/auth.json`).then(res => res.json())
.then((json) => {
let payload = {
method: "PUT",
body: JSON.stringify({
ship: json.ship,
code: code,
@tacryt-socryp
tacryt-socryp / goldbach-1.hoon
Last active May 16, 2018 22:53
Goldbach Conjecture in Hoon
/+ mylib :: import
=, mylib :: alias to the subject (don't have to type mylib anymore)
|= a=@
^- [@ [@ @]]
(goldbach a)
@tacryt-socryp
tacryt-socryp / mylib.hoon
Last active May 16, 2018 22:49
Prime number checker in Hoon
|%
++ new-prime
|= n=@
^- @
%- inner-prime [n 2]
++ inner-prime
|= a=[n=@ i=@] :: sample (input mold)
^- @ :: return mold
=+ upper=(div n.a 2) :: define a variable as the upper limit of variables to check = n/2
@tacryt-socryp
tacryt-socryp / fac-1.hoon
Last active May 16, 2018 22:52
Factorial Calculator with tail call optimization written in Hoon
/+ mylib :: import
=, mylib :: alias to the subject (don't have to type mylib anymore)
|= a=@
^- @
(new-fac a)
@tacryt-socryp
tacryt-socryp / mylib.hoon
Created May 16, 2018 22:35
Subtraction written in Hoon
|%
++ new-dec
|= a/@
^- @
?: (lte a 0) ::
0
?: (lte a 1)
0
%- inner-dec :+(a 1 0)
@tacryt-socryp
tacryt-socryp / add-1.hoon
Last active May 16, 2018 22:42
Addition written in Hoon
/+ mylib :: import
=, mylib :: alias to the subject (don't have to type mylib anymore)
|= [a=@ b=@]
^- @
(new-add a b)
@tacryt-socryp
tacryt-socryp / decrement.md
Created May 16, 2018 22:30
Decrement written in Hoon

Decrement

Write a gate that takes some integer n and returns (n - 1). You may not use dec from the Hoon stdlib, and you may not look at the code for dec in hoon.hoon. You're under the honor system.