# Sohail Qayum Malik

http://www.codeplex.com/site/users/view/cyberian

Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Loading user information from MSDN

Something went wrong getting user information from MSDN

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

http://www.codeplex.com/site/users/view/cyberian

## Modern Methods for Texture Compression

2 days agoInteresting video; watched it twice, thanks.

## Stephan T. Lavavej - Core C++, 7 of n

Dec 25, 2012 at 10:58PMMerry Christmas, great effort once again. Channel9 is my one stop destination to listen and watch this and all the other videos on C++/STL/Haskell and so on and so forth. Thank you Mr. Stephan T. Lavavej, Charles and all the other nice people at Channel9.

## Ping 161: Scroogled, Xbox sales, Windows Store wins, IE 10 trolls

Dec 07, 2012 at 3:25PMPing is nice show, I watch it almost regularly. Keep on doing this nice show. Kudos to people at Ping.

## WHOIS: Danah Boyd, MSR Social Scientist

Jan 26, 2012 at 2:03PM"Work to learn from each other."I think this is a good advice for the parents and their children(eager to socialize online).

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13

Jun 06, 2010 at 2:07PMlength' = sum . map(\_ -> 1)

length'' = (foldr (\x xs -> x + xs) 0) . (foldr (\_ xs -> [1] ++ xs) [])

all' :: (a -> Bool) -> [a] -> Bool

--all' p as = foldr (\x xs -> x && xs) True $ foldr (\x xs -> if p x then True : xs else False : xs) [True] as

all' p xs = foldr (\x xs -> p x && xs) True xs

any' :: (a -> Bool) -> [a] -> Bool

any' p xs = foldr (\x xs -> p x || xs) False xs

takewhile' :: (a -> Bool) -> [a] -> [a]

takewhile' p xs = foldr (\x xs -> if p x then x : xs else xs) [] xs

dropwhile' :: (a -> Bool) -> [a] -> [a]

dropwhile' p xs = foldr (\x xs -> if not (p x) then x : xs else xs) [] xs

Sohail Qayum Malik

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 7 of 13

Jun 05, 2010 at 8:03AMHey,

map :: (a -> b) -> [a] -> [b]

map f [] = []

map f (x:xs) = f x : Main.map f xs

map' :: (a -> b) -> [a] -> [b]

map' f [] = []

map' f xs = Main.foldr (\x xs -> f x : xs) [] xs

filter :: (a -> Bool) -> [a] -> [a]

filter f [] = []

filter f (x:xs) | f x = x : Main.filter f xs

| otherwise = Main.filter f xs

filter' :: (a -> Bool) -> [a] -> [a]

filter' f [] = []

filter' f xs = Main.foldr (\x xs -> if f x then x : xs else xs) [] xs

-- Need Integral class, since method div is provided there

even :: Integral a => a -> Bool

even a = if ((a `div` 2)*2) == a then True else False

foldr :: (a -> b -> b) -> b -> [a] -> b

foldr f v [] = v

foldr f v (x:xs) = f x (Main.foldr f v xs)

Sohail Qayum Malik

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 6 of 13

Jun 02, 2010 at 2:36AMFinally got some time and went through this lecture too...

(!!) :: [a] -> Int -> a

(a:as) !! 0 = a

(a:as) !! (n + 1) = as Main.!! n

(++) :: [a] -> [a] -> [a]

[] ++ [] = []

as ++ [] = as

[] ++ bs = bs

(a:as) ++ (bs) = a : (Main.++) as bs

(&&) :: Bool -> Bool -> Bool

True && True = True

_ && _ = False

length :: Num a => [a] -> Int

length [] = 0

length [x] = 1

length (a:as) = 1 + Main.length as

take :: Num a => Int -> [a] -> [a]

take 0 _ = []

take _ [] = []

take (n + 1) (a:as) = a : Main.take n as

drop :: Num a => Int -> [a] -> [a]

drop 0 as = as

drop _ [] = []

drop (n + 1) (a:as) = Main.drop n as

qsort :: Ord a => [a] -> [a]

qsort [] = []

qsort [a] = [a]

qsort (a:as) = qsort smaller Main.++ [a] Main.++ qsort greater

where

smaller = [x | x <- as, x <= a]

greater = [x | x <- as, a < x]

and :: [Bool] -> Bool

and [] = True

and (a:as) = a Main.&& Main.and as

concat :: [[a]] -> [a]

concat [] = []

concat (a:as) = a Main.++ Main.concat as

replicate :: Int -> a -> [a]

replicate 0 a = []

replicate (n + 1) a = a : Main.replicate n a

elem :: Eq a => [a] -> a -> Bool

elem [] _ = False

elem (a:as) s = if a == s then True else Main.elem as s

merge :: [Int] -> [Int] -> [Int]

merge [] [] = []

merge [] bs = bs

merge as [] = as

merge as bs = qsort $ as Main.++ bs

msort :: [Int] -> [Int]

msort [] = []

msort [a] = [a]

msort as = merge (msort $ Main.take n as) (msort $ Main.drop n as)

where

n = Main.length as `div` 2

Sohail Qayum Malik.

## A Conversation with Jaron Lanier

May 21, 2010 at 3:20PMNice conversation, really inspirational. I've included this talk in the list of few talks, I often hear.

Thank you.

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 5 of 13

Mar 28, 2010 at 4:33PMHey, late as usual

module Main( main, Main.sum, Main.zip ) where

main = do

print $ pyths 5

print $ perfects 500

-- print $ Main.zip [4,5,6,7] [1,2,3]

-- print $ Prelude.zip [4,5,6,7] [1,2,3]

-- print $ Main.zip [1,2,3] [4,5,6,7]

-- print $ Prelude.zip [1,2,3] [4,5,6,7]

pyths :: Int -> [(Int, Int, Int)]

pyths = \n -> [(x, y, n) | x <- [1..n], y <- [1..n], (x*x + y*y) == n*n]

perfects :: Int -> [Int]

perfects n = [x | x <- [1..n], Main.sum (factors x) == x]

factors :: Int -> [Int]

factors = \n -> [x | x <- [1..n], x < n && n `mod` x == 0]

sum :: [Int] -> Int

sum [] = 0

sum (a:as) = a + Main.sum as

zip :: [Int] -> [Int] -> [(Int, Int)]

zip as bs = dropper (pairs as bs) (length bs)

pairs :: [Int] -> [Int] -> [(Int, Int)]

pairs as bs = [(x,y) | x <- as, y <- bs]

dropper :: [(Int,Int)] -> Int -> [(Int,Int)]

dropper [] _ = []

dropper (a:as) n = [a] ++ dropper (drop n as) n

Sohail Qayum Malik

## C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 4 of 13

Mar 26, 2010 at 7:14PMVery late to the class... again

my shot at the homework. Incomplete, of course.

--Case of dynamic dispatch...

class Bool {

public:

virtual Bool* operator!(void) = 0;

virtual Bool* operator&&(Bool&) = 0;

virtual Bool* operator||(Bool&) = 0;

};

class True : public Bool {

Bool* operator!(void);

Bool* operator&&(Bool& ref) {

return &ref;

}

Bool* operator||(Bool& _) {

return new True();

}

};

class False : public Bool {

Bool* operator!(void);

Bool* operator&&(Bool& _) {

return new False();

}

Bool* operator||(Bool& ref) {

return &ref;

}

};

Bool* True::operator!(void) {

return new False();

}

Bool* False::operator!(void) {

return new True();

}

int main(void) {

class Bool *Bt = new True();

class Bool *Bf = new False();

*Bt&&*Bf;

*Bf&&*Bt;

*Bf||*Bt;

!*Bf;

return 0;

}

--Case of double dispatch...

#include <iostream>

using namespace::std;

class Bool {

public:

virtual Bool* AND(Bool&) = 0;

// TF is for true or false

virtual Bool* TF(void) = 0;

};

class True : public Bool {

Bool* TF(void) {

cout<<"True"<<endl;

return new True();

}

Bool* AND(Bool& ref) {

return ref.TF();

}

};

class False : public Bool {

Bool* TF(void) {

cout<<"False"<<endl;

return new False();

}

Bool* AND(Bool&) {

return TF();

}

};

int main(void) {

Bool *Bt = new True();

Bool *Bf = new False();

Bt->AND(*Bf);

Bf->AND(*Bt);

Bt->AND(*Bt);

return 0;

}

Sohail Qayum Malik

See more comments…