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
#lang sweet-exp stacklisp | |
provide | |
rename-out void identity | |
define-variable! | |
set-variable-value! | |
lookup-variable-value | |
extend-environment | |
tag | |
rename-out allocate-words allocate |
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 System( getArgs ) | |
import System.Console.GetOpt | |
import System.IO | |
import Ratio | |
import Numeric | |
{- Returns the binomial coefficient. -} | |
binomial m 0 = 1 | |
binomial 0 n = 0 | |
binomial (m+1) (n+1) = (binomial m n) * (m+1) `div` (n+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
#include <iostream> | |
#include <deque> | |
#include <functional> | |
#include <string> | |
#include <list> | |
#include <algorithm> | |
using namespace std; | |
union Integer; |
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 System.IO.Temp | |
import System.IO.Unsafe | |
import System.Process | |
import Data.Text | |
debugDiffIO :: Show a => a -> a -> IO (Maybe Text) | |
debugDiffIO x y = do | |
xf <- writeSystemTempFile "x" $ show x | |
yf <- writeSystemTempFile "y" $ show y | |
(exitCode, result, _) <- readProcessWithExitCode "git" ["diff", "--no-index", "--color-words=.", xf, yf] "" |
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
f x = if even x then x `div` 2 else reduce (3 * x + 1) where reduce x | even x = reduce $ x `div` 2 ; reduce x = x | |
until (\x -> f x == x) f 19 | |
1 |