This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| Transform a string to title case. | |
| Usage: | |
| {{ myString | titleCase }} | |
| */ | |
| angular |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Safetails where | |
| safetail :: Eq a => [a] -> [a] | |
| safetail xs = if xs == [] then [] else tail xs | |
| safetail' :: Eq a => [a] -> [a] | |
| safetail' xs | |
| | xs == [] = [] | |
| | otherwise = tail xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Quicksort where | |
| quicksort :: (Ord a) => [a] -> [a] | |
| quicksort [] = [] | |
| quicksort (x:xs) = quicksort [y | y <- xs, y <= x] ++ [x] ++ quicksort [y | y <- xs, y > x] | |
| quicksort' :: (Ord a) => [a] -> [a] | |
| quicksort' [] = [] | |
| quicksort' (x:xs) = (quicksort' small) ++ [x] ++ (quicksort' big) | |
| where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var hasOwnProperty = Object.prototype.hasOwnProperty; | |
| function isEmpty(obj) { | |
| if (obj == null) return true; | |
| if (obj.length > 0) return false; | |
| if (obj.length === 0) return true; | |
| if (typeof obj !== "object") return true; | |
| for (var key in obj) { | |
| if (hasOwnProperty.call(obj, key)) return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Display a dropdown menu on hover rather than on click. Useful for navigation menus. | |
| Tested with [email protected] | |
| */ | |
| .dropdown:hover .dropdown-menu { | |
| display: block; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- fibonacci.hs | |
| -- credit dtb@stackoverflow http://stackoverflow.com/a/1105840 | |
| -- Accessing the n-th fibonacci number: fib n = fibs !! n | |
| module Fibonacci where | |
| fib :: Integer -> Integer | |
| fib 0 = 1 | |
| fib 1 = 1 | |
| fib n = fib (n-1) + fib (n-2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Reverse where | |
| reverse :: [a] -> [a] | |
| reverse [] = [] | |
| reverse (x:xs) = reverse xs ++ [x] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Length where | |
| length :: [a] -> Int | |
| length [] = 0 | |
| length (_:xs) = 1 + length xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Palindrome where | |
| palindrome :: Eq a => [a] -> Bool | |
| palindrome [] = True | |
| palindrome [_] = True | |
| palindrome xs = (head xs) == (last xs) && (palindrome $ init $ tail xs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Compute the factorial of n recrusively | |
| module Factorial where | |
| factorial :: Int -> Int | |
| factorial 0 = 1 | |
| factorial n = n * factorial (n-1) |
OlderNewer