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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef void (*func) (const char *); | |
struct module { | |
func print; | |
func println; | |
}; |
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
;; Packages. | |
(require 'package) | |
(add-to-list 'package-archives | |
(cons "melpa-stable" "http://stable.melpa.org/packages/") t) | |
(package-initialize) | |
(add-to-list 'load-path "~/elisp") ;; for saving some custom code. | |
;; Save customizations in a separate file. | |
(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) |
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
;; Packages. | |
(require 'package) | |
(add-to-list 'package-archives | |
(cons "melpa-stable" "http://stable.melpa.org/packages/") t) | |
(package-initialize) | |
(add-to-list 'load-path "~/elisp") ;; for saving some custom code. | |
;; Save customizations in a separate file. | |
(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) |
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
module Main where | |
import Data.Array | |
import Data.List | |
import Data.Ord | |
import Text.Printf | |
type Coord = (Int, Int) | |
type Size = (Int, Int) |
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.Ratio | |
main :: IO () | |
main = print $ result 5 | |
result :: Integer -> Rational | |
result size = abs $ sum | |
[ fromIntegral mult * infTailSum size d | |
| (mult, d) <- coeffs size | |
] |
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 Control.Monad | |
import System.Random | |
import Data.List | |
size :: Int | |
size = 3 | |
steps :: Int | |
steps = 10000 |
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
module Q where | |
data Quarter = NE | NW | SE | SW deriving Show | |
type Vector = (Float, Float) | |
quarter :: Vector -> Vector -> Quarter | |
quarter look target = detect $ angle look - angle target | |
detect :: Float -> Quarter | |
detect x |
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
(define l_y1 :: int) | |
(define l_y2 :: int) | |
(define l_y3 :: int) | |
(define l_x1 :: int) | |
(define l_x2 :: int) | |
(define l_x3 :: int) | |
(define l_x4 :: int) | |
(assert (<= l_x1 3)) | |
(assert (>= l_x1 0)) |
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
module Main where | |
import Data.List (maximumBy) | |
import Data.Word (Word64) | |
import Data.Array.IO (IOUArray, newArray, readArray, writeArray, unsafeFreeze) | |
import Data.Array.Unboxed (UArray) | |
import Data.Array.IArray (assocs) | |
import Control.Monad (forM_) | |
type Cache = IOUArray Word64 Word64 |
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
primes :: [Integer] | |
primes = sieve [2..] | |
where | |
sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0] | |
main = print $ primes !! 10000 | |
-- compile with `ghc --make primes.hs`, then run run run :) |
NewerOlder