Skip to content

Instantly share code, notes, and snippets.


Ashutosh Mehra ashutoshmehra

View GitHub Profile
View gist:0d26f6a831f60685d6b4
### Keybase proof
I hereby claim:
* I am ashutoshmehra on github.
* I am ashutoshmehra ( on keybase.
* I have a public key whose fingerprint is 366E 3FD5 75AC 22ED 9F5C 585D BB39 438B E008 71D6
To claim this, I am signing this object:
ashutoshmehra / sudoku.hs
Created Aug 13, 2009
Peter Norvig's beautiful Python program ( now in Haskell!
View sudoku.hs
-- Peter Norvig's beautiful Python program (
-- that uses constraint propagation (and ultimately searching)
-- to solve Sudoku instances
-- Now in everybody's favorite language!
-- Haskell coding by Ashutosh Mehra (
import List (elem, nub, filter, delete, intersperse, replicate)
import Data.Map (Map, fromList, (!), insert, keys, elems, toList)
import Data.List (intercalate)
View recursive_postfix_eval.c
/* Solves the puzzle: Puzzle: recursive postfix evaluation.
#include <stdio.h>
#define F 0x40
char eval(int * pr) {
char ch;
int val;
switch((ch = getchar())) {
ashutoshmehra / gist:93143
Created Apr 10, 2009
2-space indents, never tabs
View gist:93143
(setq-default c-basic-offset 2)
(setq-default indent-tabs-mode nil)
ashutoshmehra / gist:93142
Created Apr 10, 2009
indents are to be real tab character worth 8-space
View gist:93142
'((c++-mode . ((c-basic-offset . 8)
(tab-width . 8)
(indent-tabs-mode . t)))))
"d:/work/BeautifulCode/" 'beautiful-code)
ashutoshmehra / MemoFib.hs
Created Mar 17, 2009
Memoized Fibonacci using GHC's inline (code from AndyGill's blog post)
View MemoFib.hs
-- Code from:
module Main where
import GHC.Exts
type Nat = Int
memo :: (Nat -> Integer) -> [Integer]
memo f = map f [0..]
apply :: [Integer] -> (Nat -> Integer)
apply xs n = xs !! n
You can’t perform that action at this time.