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
| (defn lazy-sort | |
| ([input-seq] | |
| (lazy-sort (merge-step [(first input-seq)] [(second input-seq)]) (drop 2 input-seq))) | |
| ([partial-result input-seq] | |
| (let [result-length (count partial-result)] | |
| (if (seq input-seq) | |
| (recur (merge-step partial-result (divide-step (take result-length input-seq))) (drop result-length input-seq)) | |
| partial-result)))) |
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
| > function integerFactory() { | |
| var n=0; | |
| return function() { | |
| return n++; | |
| }; | |
| }; | |
| undefined | |
| > next_integer = integerFactory(); | |
| function () { return n++; } | |
| > next_integer(); |
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
| > function fibonacciFactory() { | |
| var a=0, b=1; | |
| return function() { | |
| var next=a+b; | |
| a=b, b=next; | |
| return a; | |
| }; | |
| }; | |
| undefined | |
| > next_fibonacci = fibonacciFactory(); |
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
| function newton_square_root(x, e) { | |
| var guess = 1; | |
| while (Math.abs(x - guess*guess) > e) | |
| guess -= (guess*guess-x) / (2*guess); | |
| return guess; | |
| } |
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
| function squareGuessFactory(x) { | |
| var guess=1; | |
| return function() { | |
| guess -= (guess*guess-x) / (2*guess); | |
| return guess; | |
| }; | |
| }; | |
| function newton_square_root(x, e) { |
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
| function range() { | |
| switch (arguments.length) { | |
| case 1: | |
| var start=0, stop=arguments[0], step=1; | |
| break; | |
| case 2: | |
| var start=arguments[0], stop=arguments[1], step=1; | |
| break; | |
| case 3: | |
| var start=arguments[0], stop=arguments[1], step=arguments[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
| // ==UserScript== | |
| // @name reddit comment animation | |
| // @namespace git2samus | |
| // @include http://www.reddit.com/* | |
| // @match http://www.reddit.com/* | |
| // ==/UserScript== | |
| /* Frame class: | |
| * represents a single frame in the animation | |
| */ |
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
| // ==UserScript== | |
| // @name mangareader | |
| // @namespace git2samus | |
| // @include http://www.mangareader.net/* | |
| // @match http://www.mangareader.net/* | |
| // ==/UserScript== | |
| if (document.getElementById('imgholder')) | |
| window.location.hash = '#imgholder'; |
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
| fun! TextMode(mode) range | |
| if a:mode == 'textmode' | |
| setlocal filetype=text | |
| setlocal wrap | |
| setlocal nolist | |
| setlocal linebreak | |
| nnoremap <buffer> j gj | |
| nnoremap <buffer> k gk | |
| nnoremap <buffer> 0 g0 | |
| nnoremap <buffer> $ g$ |
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
| try: | |
| from local_settings import * | |
| except ImportError: | |
| pass |