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
| int hammingDistance(int a, int b) { | |
| int accum = 0; | |
| for(int c = a ^ b; c; c >>= 1) { | |
| accum += c & 1; | |
| } | |
| return accum; | |
| } |
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
| {-# LANGUAGE Rank2Types #-} | |
| module Main where | |
| main = print $ f succ' 'c' 4 | |
| succ' :: (forall a . (Enum a) => a -> a) | |
| succ' = succ | |
| f :: (Enum c, Show c, Enum d, Show d) => (forall a . (Enum a) => a->a) -> c -> d -> String | |
| f g c d = show (g c) ++ show (g d) |
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
| qsort = (list) -> | |
| return list if list.length <= 1 | |
| pivotPoint = medianOfThree list | |
| pivot = list[pivotPoint] | |
| list.splice pivotPoint, 1, [] | |
| [left, right] = partition list, (e) -> e < pivot | |
| [(qsort left)..., pivot, (qsort right)...] | |
| medianOfThree = (list) -> | |
| return 0 if list.length < 3 |
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
| :%s/[\r \t]\+$// | |
| :%s/() ->/->/c | |
| :%s/if \!/unless /c | |
| :%s/;$//c | |
| :%s/^\(\s*\)\(@\?[a-z0-9$_]\+\)()/\1do \2/ic | |
| :%s/\!==?/isnt/c | |
| :%s/===\?/is/c | |
| :%s/\([a-z0-9$_]\)(\([^)]\+\))$/\1 \2/ic | |
| :%s/true/yes/c | |
| :%s/false/no/c |
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
| for b in a | |
| for c in b | |
| for d in c | |
| do d | |
| wtf = -> d = 0 # wtf, no declaration? |
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
| "a#{b}cd#{"e"}f" |
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
| start = program | |
| program = (_ "\n")* (_ toplevelBlock)? | |
| toplevelBlock = toplevelStatement (_ TERMINATOR _ toplevelStatement)* TERMINATOR? | |
| toplevelStatement = !(return / continue / break) statement | |
| block = statement (_ TERMINATOR _ statement)* TERMINATOR? | |
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
| INDENT DEDENT | |
| """ """ | |
| ''' ''' | |
| " " | |
| ' ' | |
| ### ### | |
| # \n | |
| /// /// | |
| / / | |
| ` ` |
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
| make build && node testParser.js < someFileYouWouldLikeToParse.coffee |
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/coffee --debug --js -i test.coffee | |
| ### PREPROCESSED ### | |
| 1 : f -> | |
| 2 : (INDENT)a 0, yes | |
| 3 : b 0.1, this | |
| 4 : (DEDENT) | |
| ### PARSED ### | |
| { type: 'CS.Program', | |
| block: | |
| { type: 'CS.Block', |