Skip to content

Instantly share code, notes, and snippets.

View leroux's full-sized avatar

Muhaimin A leroux

View GitHub Profile
module Queue where
data Queue a = Queue [a] [a]
deriving (Show, Eq)
emptyQueue :: Queue a
emptyQueue = Queue [] []
push :: a -> Queue a -> Queue a
push x (Queue d e) = Queue d (x:e)
@leroux
leroux / Chain.hs
Last active December 19, 2015 17:08
Haskell Chain
module Chain where
infixl 2 .>
infixr 1 .>>
{-| Chain operator.
Chain functions in a do-like (monadic bind)-like style.
`f .> g` will return a function that will apply f, then apply g.
It can be alternatively be defined as: `f .> g = g . f` which is just
`flip (.)`.
@leroux
leroux / reverseme.c
Created August 18, 2012 01:59
Reverse str back to 'password'.
#include <stdio.h>
int main (void) {
char str[] = "password";
int i = 0;
/* for pointer arithmetic */
char *ptr = str;
while (*ptr && (*ptr += (i++)))
ptr++;
printf("%s\n", str);
@leroux
leroux / kiyoura.c
Created August 16, 2012 20:57
Kiyoura's Reverse String Challenge Solution
#include <stdio.h>
int main (void) {
char str[] = "password";
int i = 0;
/* for pointer arithmetic */
char *ptr = str;
while (*ptr && (*ptr += (i++)))
ptr++;
printf("%s\n", str);