Skip to content

Instantly share code, notes, and snippets.

View BRonen's full-sized avatar
:shipit:
ora et labora

Brenno Rodrigues BRonen

:shipit:
ora et labora
View GitHub Profile
@BRonen
BRonen / LinkedList.hs
Created June 4, 2023 06:14
An example of linked list made in haskell for fun
module Main where
data List a = End a | Node a (List a) deriving (Show)
prepend :: a -> List a -> List a
prepend value x = Node value x
append :: a -> List a -> List a
append value (End x) = Node x (End value)
append value (Node x y) = Node x (append value y)
@BRonen
BRonen / KeyValue.hs
Created June 3, 2023 18:14
A key value data structure made in haskell just for fun
module Main where
type Pair a = ( [Char], a )
updateValue :: [Char] -> a -> [Pair a] -> [Pair a]
updateValue key value [] = [(key, value)]
updateValue key value [(a, b)]
| a == key = [(key, value)]
| otherwise = [(a, b), (key, value)]
updateValue key value ((a, b):xs)
@BRonen
BRonen / BinaryTree.hs
Last active June 3, 2023 14:50
A binary tree implemented in haskell just for fun
module Main where
data Tree a = Leaf a | Node (Tree a) (Tree a)
stringifyTree :: Tree Integer -> [Char]
stringifyTree (Leaf x) = show x
stringifyTree (Node left right) = " {" ++ (stringifyTree left) ++ "} - {" ++ (stringifyTree right) ++ "} "
dump :: Tree a -> [a]
dump (Leaf x) = [x]
@BRonen
BRonen / full_adder.html
Last active March 7, 2024 20:42
Full adder made to prove that html with css is turing complete (without js)
<!DOCTYPE html>
<html>
<head>
<style>
div {
display: flex;
gap: 1rem;
}
const code1 = '((7 1 +) 5 +) ((8 ((8 ((8 3 +) 1 +) +) 1 +) +) 1 +) +';
const code2 = '4 3 -';
const code3 = '(2 3 +) (23 21 +) +';
const operators = {
'+': (args) => args[0] + args[1],
'-': (args) => args[0] - args[1],
'*': (args) => args[0] * args[1],
'/': (args) => args[0] / args[1],
};