This file contains hidden or 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
| 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) |
This file contains hidden or 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
| 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) |
This file contains hidden or 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
| 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] |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <style> | |
| div { | |
| display: flex; | |
| gap: 1rem; | |
| } |
This file contains hidden or 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
| 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], | |
| }; |
NewerOlder