🏳️🌈
This file contains 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
#!/usr/bin/env python3 | |
import code | |
import ctypes | |
import inspect | |
import logging | |
def hook( | |
banner_msg: str | None = None, |
This file contains 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
class Lazy: | |
def __init__(self, fun, *args, **kwargs): | |
self.fun = fun | |
self.args = args | |
self.kwargs = kwargs | |
self.executed = False | |
self.value = None | |
# Binary Operators | |
def __binary__(self, binfun, other): |
This file contains 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
package main; | |
public interface Lazy<R> { | |
public R force(); | |
} |
This file contains 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
-- Compile with -threaded | |
import System.IO | |
import Control.Concurrent | |
import Control.Concurrent.STM | |
-- (<Sum>, <Number of finished transactions>) | |
type Result = TVar (Int, Int) | |
-- Adds x to result and increments the number of finished transactions |
This file contains 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
-- Compile with -threaded | |
import System.IO | |
import Control.Concurrent | |
getGreeting :: IO String | |
getGreeting = do | |
-- Get id and convert to string | |
tid <- myThreadId | |
let greeting = "Hello from " ++ show tid |
This file contains 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
-- Compile with the -XScopedTypeVariables flag. | |
-- e.g. ghc -Wall -XScopedTypeVariables Main.hs | |
import Control.Exception | |
data MyError = Error deriving Show | |
instance Exception MyError | |
failing :: IO () |
This file contains 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
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. | |
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis |
This file contains 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
import Data.List | |
import Data.Char | |
import System.IO | |
getSearchWords :: IO [String] | |
getSearchWords = do | |
putStrLn "Specify the words to search:" | |
aux | |
where | |
aux = do |
This file contains 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
import Data.List hiding (insert) | |
import Test.QuickCheck | |
data Tree a = Leaf | Node (Tree a) a (Tree a) | |
deriving Show | |
-- Exercise 1 | |
inv_tup_tree = aux (0,0) | |
where | |
aux (l,r) = Node (aux $ (l+1,r)) (l,r) (aux $ (l,r+1)) |
This file contains 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
rev :: [a] -> [a] | |
rev = foldl (\acc x -> x : acc) [] | |
--rev = foldl (flip (:)) [] | |
prefixes :: [a] -> [[a]] | |
prefixes = foldr (\x acc -> [x] : (map ((:) x) acc)) [] | |
lagrange :: [(Float, Float)] -> Float -> Float | |
lagrange xs x = foldl (\acc (xj,y) -> acc + (y * l xj)) 0 xs | |
where |
NewerOlder