Skip to content

Instantly share code, notes, and snippets.

View vijayanant's full-sized avatar

Vijay Anant vijayanant

View GitHub Profile
@vijayanant
vijayanant / carncdr.py
Created June 4, 2021 15:47
Simple Python problem #1 --- pair, car, and cdr
# Problem Statement
# cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair.
# For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.
# Given the below implementation for cons( ), please implement car & cdr
def cons(a, b):
def pair(f):
return f(a, b)
return pair
@vijayanant
vijayanant / gadt1.hs
Created April 8, 2020 03:45
GADT Code Samples
data Point = Pt Int Int
data Expr a = Number Integer | Boolean Bool
@vijayanant
vijayanant / Git Branching and Releasing for Happy Developers.md
Last active July 29, 2019 14:22
Git Branching and Releasing for Happy Developers

Git Branching and Realeasing

AIM

To make below listed activites simple (from SCM point of view)

  • Adding new features
  • Fixing bugs
  • Preparing for release
  • Deploying to production
  • Applying hotfixes
  • Versioning
@vijayanant
vijayanant / TypeFamilies.hs
Created November 30, 2018 17:40
Type Families - WIP
{-# LANGUAGE TypeFamilies
, DataKinds
, PolyKinds
, TypeInType
, TypeOperators
, UndecidableInstances
, RankNTypes
#-}
@vijayanant
vijayanant / README.md
Created November 27, 2018 03:17 — forked from m-ammar/README.md
haskell-resources
@vijayanant
vijayanant / HigherRankedTypes.hs
Last active June 28, 2024 19:29
Rank N Types in Haskell
{-# LANGUAGE RankNTypes #-}
module RankN where
-- Rank 0:
-- add1 is momomorphic
add1 :: Int -> Int
add1 x = x + 1
-- Rank 1

Keybase proof

I hereby claim:

  • I am vijayanant on github.
  • I am vijayanant (https://keybase.io/vijayanant) on keybase.
  • I have a public key ASATAASxUzx1ZqEy4JGeIrlA1oyzEk6jSPdtXtZPglZs_Qo

To claim this, I am signing this object:

@vijayanant
vijayanant / Applicatives.hs
Last active January 17, 2020 13:54
Choose Wisely
-- 1 + 2
-- (+) 1 2
-- + (Just 1) (Just 2)
-- Monadic desugared
(Just 1) >>= (\x -> (Just 2) >>= \y -> return (x+y))
-- Monadic sugar
@vijayanant
vijayanant / Tree.hs
Last active November 4, 2018 14:40
Binary Tree type and traversal in Haskell, Python, and Java
data Tree a = Empty | Node (Tree a) a (Tree a)
deriving (Show)
fromList :: [a] -> Tree a
fromList xs
| null xs = Empty
| otherwise = Node (fromList x1) x (fromList x2)
where (x1, x:x2) = splitAt (length xs `div` 2) xs
inorder :: Tree a -> [a]