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
| import System.Random | |
| f :: [a] -> IO a | |
| f xs = f' xs [] 1 where | |
| f' :: [a] -> [a] -> Int -> IO a | |
| f' [] z _ = return $ head z | |
| f' (x:xs) z i = do r <- randomRIO (1,i) | |
| if r == 1 | |
| then f' xs [x] (i + 1) | |
| else f' xs z (i + 1) |
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
| import Data.Map (Map) | |
| import qualified Data.Map as Map | |
| import Data.Foldable | |
| isAnagram :: [Char] -> [Char] -> Bool | |
| isAnagram xs ys = f xs ys Map.empty | |
| where | |
| f :: [Char] -> [Char] -> Map Char Int -> Bool | |
| f (x:xs) ys m = if x `Map.member` m |
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
| #!/bin/bash | |
| JSCSS=$'/* Copyright (C) 2014 Wesleyan University | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * |
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
Show hidden characters
| { | |
| //Enforcing options | |
| "bitwise" : true, // no bitwise operators | |
| "camelcase" : true, // variable names camelCase or UPPER_CASE | |
| "curly" : true, // curly braces around blocks | |
| "eqeqeq" : true, // no == and != | |
| "es3" : false, // ECMAScript 3 specification | |
| "forin" : true, // for in loops must filter object's items | |
| "freeze" : false, // prevent overwriting native objects | |
| "immed" : true, // immediate function invocations must be wrapped in () |
NewerOlder