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
| // ==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
| 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
| 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 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 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 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
| (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
| (defn merge-step | |
| ([seq1 seq2] | |
| (merge-step [] seq1 seq2)) | |
| ([result seq1 seq2] | |
| (let [head1 (first seq1) | |
| head2 (first seq2)] | |
| (cond | |
| (nil? head1) (concat result seq2) | |
| (nil? head2) (concat result seq1) | |
| :else (if (< head1 head2) |
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 merge-step [seq1 seq2] | |
| (let [head1 (first seq1) | |
| head2 (first seq2)] | |
| (cond | |
| (nil? head1) seq2 | |
| (nil? head2) seq1 | |
| :else (if (< head1 head2) | |
| (cons head1 (merge-step (rest seq1) seq2)) | |
| (cons head2 (merge-step seq1 (rest seq2))))))) |