Skip to content

Instantly share code, notes, and snippets.

@prakashk
prakashk / rename-lost-files.hs
Last active August 29, 2015 13:59
rename files in git lost-found directory
-- rename Project Euler files in git lost-found directory
-- get the file type and the problem number from the initial comments
-- in each file
import System.Directory
import Text.Regex.Posix
import Control.Monad (forM_)
lostFilesDir = ".git/lost-found/other"
@prakashk
prakashk / rename-lost-files-2.hs
Created April 17, 2014 04:25
rename files in git lost-found directory - v2
-- rename Project Euler files in git lost-found directory
-- get the file type and the problem number from the initial comments
-- in each file
import System.Directory
import Text.Regex.Posix
import Control.Monad (forM_)
lostFilesDir = ".git/lost-found/other"
@prakashk
prakashk / rename-lost-files-3.hs
Created April 21, 2014 20:46
rename lost files - v3
-- rename Project Euler files in git lost-found directory
-- get the file type and the problem number from the initial comments
-- in each file
import System.Environment
import System.Directory
import Text.Regex.Posix
import Control.Monad (forM_)
@prakashk
prakashk / gist:e464478b2697c5ef2eaa
Last active August 29, 2015 14:01
Implementation of few haskell builtins
-- https://questhub.io/realm/haskell/quest/537bb4e2bbd0bed61d00007d
head :: [a] -> a
head [] = error "head: empty list"
head (x:xs) = x
tail :: [a] -> [a]
tail [] = error "tail: empty list"
tail (x:xs) = xs
import System.Environment (getArgs)
import Text.Parsec
import Text.Parsec.Prim
import Text.Parsec.Language
import qualified Text.Parsec.Token as T
import Control.Applicative ((<$>), (*>))
type Parser = Parsec String ()
-- AST
import System.Environment (getArgs)
import Text.Parsec
import Text.Parsec.Prim
import Text.Parsec.Language
import qualified Text.Parsec.Token as T
import Control.Applicative ((<$>), (*>), (<*>), pure)
type Parser = Parsec String ()
-- AST
import System.Environment (getArgs)
import Text.Parsec
import Text.Parsec.Prim
import Text.Parsec.Language
import qualified Text.Parsec.Token as T
import Control.Applicative ((<$>), (*>), (<*>), pure, liftA2)
type Parser = Parsec String ()
type Location = String
type LocNode a = (Location, a)
import System.Environment (getArgs)
import Text.Parsec
import Text.Parsec.Prim
import Text.Parsec.Language
import qualified Text.Parsec.Token as T
import Control.Applicative ((<$>), (*>), (<*>), pure, liftA2)
import Data.List (intercalate)
type Parser = Parsec String ()
type Location = String
### the patch passes the following tests :)
#?rakudo todo 'unicode'
{ # distribution for unary prefix
my @r;
@r = -« ([1, 2], [3, [4, 5]]);
my @e = ([-1, -2], [-3, [-4, -5]]);
is(~@r, ~@e, "distribution for unary prefix");
@r = -<< ([1, 2], [3, [4, 5]]);
diff --git a/bin/book-to-latex b/bin/book-to-latex
index a909a46..f3f1018 100644
--- a/bin/book-to-latex
+++ b/bin/book-to-latex
@@ -12,6 +12,7 @@ print <<'HEADER';
\usepackage[utf8]{inputenc}
\usepackage{makeidx}
\usepackage[colorlinks=true,pagebackref]{hyperref}
+\usepackage{wrapfig}