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
| 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 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
| 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 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
| 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 |
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
| elem :: (Eq a) => a -> [a] -> Bool | |
| elem _ [] = False | |
| elem e (x:xs) = (e == x) || (elem e xs) | |
| nub :: (Eq a) => [a] -> [a] | |
| nub [] = [] | |
| nub (x:xs) | |
| | x `elem` xs = nub xs | |
| | otherwise = x : nub 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
| #!/usr/bin/python3 | |
| from json import loads | |
| from requests import get | |
| g = get("https://ifconfig.co/json") | |
| if not g.ok: | |
| print("Failure connecting to ifconfig.co") | |
| exit(-1) |
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
| #!/usr/bin/python3 | |
| import os | |
| import re | |
| import argparse | |
| import subprocess | |
| from functools import reduce | |
| def run_cmd(path, cmd, verbose): | |
| for i, el in enumerate(cmd): |
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
| (* ocamlc unix.cma xmas.ml *) | |
| type color = RST | RED | GRN | YEL | BLU | MAG | CYN | WHT | |
| let rec mult_list n l = if n <= 0 then [] else l @ (mult_list (n-1) l) | |
| let tree_elems = (mult_list 5 [GRN, ">"; GRN, "<"]) @ | |
| [RED, "@"; BLU, "O"; MAG, "o"; YEL, "*"] | |
| let snow_elems = (mult_list 15 [" "]) @ [".";",";"'";"*"] |
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
| #!/usr/bin/python3 | |
| import sys | |
| def readFile(path): | |
| with open(path, 'r', encoding='utf-8') as file: | |
| return int(file.read()) | |
| def writeFile(path, value): | |
| with open(path, 'w', encoding='utf-8') as file: |
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
| package main | |
| import ( | |
| "os" | |
| "strconv" | |
| "fmt" | |
| "github.com/mxk/go-sqlite/sqlite3" | |
| "golang.org/x/net/html" | |
| "net/http" | |
| "strings" |
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
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| "math/rand" | |
| "time" | |
| ) | |
| func generate_prime(min int, max int, result chan int) { |
NewerOlder