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 json | |
| import os.path | |
| import re | |
| import sys | |
| def parse(prog): | |
| result = [] | |
| entry = {} | |
| mkey = None | |
| mvalue = None |
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
| {"title": "ぶろぐー"} |
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
| > python -c "print('console.log do -> 1')" | coffee -s -n | |
| Block | |
| Call | |
| Value "console" | |
| Access "log" | |
| Call | |
| Code | |
| Block | |
| Value "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
| class Brainfuck | |
| _parse = (prog) -> | |
| prog.match(/[-+><\.,\[\]]/g) | |
| @run: (prog, input=prompt, output=console.log.bind(console)) -> | |
| _memory = [] | |
| _pointer = 0 | |
| _pc = 0 | |
| _depth = 0 | |
| prog = _parse prog | |
| while prog[_pc] |
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
| Object.defineProperty(String.prototype, 'map', { | |
| value: function () { | |
| return Array.prototype.map.apply(this, arguments).join(''); | |
| }, | |
| enumerable: false, | |
| configurable: true, | |
| writable: 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
| let swapcase c = match c with | |
| | 'A' .. 'Z' -> Char.lowercase c | |
| | 'a' .. 'z' -> Char.uppercase c | |
| | _ -> c | |
| let swapcase_s s = String.map swapcase s;; | |
| swapcase_s "AbC";; (* => "aBc" *) |
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
| (* 試す *) | |
| let f = function | |
| | [| x; (_, _) |] -> x | |
| | _ -> 0, 0;; | |
| f [| 1, 2; 3, 4 |];; (* => (1, 2) *) | |
| let f = function | |
| | [| x; _ |]::_ -> x | |
| | _ -> 0, 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
| 3 |> fun x -> x * 2 |> succ;; (* => 7 *) | |
| succ @@ (fun x -> x * 2) @@ 3;; (* => 7 *) |
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
| parse = (prog) -> | |
| prog = prog.replace /[^><\[\],.+-]/g, '' | |
| if prog.length is 0 | |
| return [] | |
| c = 0 | |
| result = (prog.match /([+]+|[-]+|[>]+|[<]+|.)/g).map (m) -> | |
| if m[0] is '[' | |
| 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
| // f(2130706433) === '127.0.0.1'; | |
| function f(n) { | |
| return [ | |
| (n & 0xff << 24) >> 24, | |
| (n & 0xff << 16) >> 16, | |
| (n & 0xff << 8) >> 8, | |
| n & 0xff | |
| ].map(String).join('.'); | |
| } |