
Recent Posts
Recent Comments
Archives
Categories
Meta
Monthly Archives: October 2012
Haskell : Btree operations
data BT a = Leaf a Node (BT a) (BT a) Empty deriving (Show,Eq) — creating unbalanced tree from List mkTree (x:y:xs) = Node (Node (Leaf x ) (Leaf y ) ) (mkTree xs) mkTree [] = Empty mkTree [x] … Continue reading
Haskell version of currency conversion
Wrote one Java version on currency convertor https://ratndeo.wordpress.com/2012/10/23/javasubmissiontointerfaces/ Here comes sophisticated Haskell version : data Operation = Add  Sub Mul Div deriving (Show,Eq) data Unit = Unit  Dollar  INR  EURO deriving (Show,Eq) data UnitPair = UnitPair … Continue reading
Java Submission to interfaces!!!
A common currency operation and exchange taken from a book : a demonstration in dummy code (50$ + 100INR 30 EURO) convert to EURO Solution : Convert currency operation and exchange to one interface
Haskell default equality
Haskell does some nice work for us .It defines default equality for us based on value constructor,a simple illustration : data Color = Red GreenBlue deriving (Show) instance Eq Color where a == b = case (a ,b ) of … Continue reading
Posted in Uncategorized
Leave a comment
Converter in haskell
{# LANGUAGE MultiParamTypeClasses #} data Km =Km Double deriving (Show,Eq) data Mile = Mile Double deriving (Show,Eq) data MyMile = MyMile Double deriving (Show,Eq) class Converter a b where convert:: a>b instance Converter (Km ) (Mile ) where convert (Km … Continue reading
Posted in Uncategorized
Leave a comment
Haskell list splitter
split _ [] = [[]] split a xs = let (ys,zs) = break (==a) xs in ys:case zs of [] >[] _> split a $ tail zs –sample run split ‘,’ “hello ryan, dont play too much,take some sleep” [“hello … Continue reading
Posted in Uncategorized
Leave a comment
Haskell :Data structure for Optional Values
Java folks must appreciate ,that Haskell does not have Null type For optional values it got elegant solution – Maybe a = Just a Nothing for example [Just 1,Just 2,Just 3,Nothing ] is a list of type Maybe Integer and … Continue reading
Posted in Uncategorized
Leave a comment