This file contains 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
data = function() { | |
var sin = [], | |
cos = []; | |
for (var i = 0; i < 100; i++) { | |
sin.push({ | |
x: i, y: Math.sin(i/10)} | |
); | |
cos.push({ | |
x: i, y: .5 * Math.cos(i/10)} | |
); |
This file contains 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
def multiplication_table(n) | |
str = " |" + (" %3d" * n) % [*1..n] | |
str += "\n" | |
str += "----+" + "----" * n | |
str += "\n" | |
1.upto(n) do |x| | |
str += "%3d |" % x | |
1.upto(x-1) {|y| str += " "} | |
x.upto(n) {|y| str += " %3d" % (x*y)} | |
str += "\n" |
This file contains 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 cartesianProductOf() { | |
return _.reduce(arguments, function(a, b) { | |
return _.flatten(_.map(a, function(x) { | |
return _.map(b, function(y) { | |
return x.concat([y]); | |
}); | |
}), true); | |
}, [ [] ]); | |
}; |
This file contains 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 bar(x) { | |
return x + x; | |
} |
This file contains 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
print "Hello from Gist PHP!"; |
This file contains 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 Voice { | |
public function loud($text) { | |
return $text . '!!!!!!'; | |
} | |
} | |
$lang = new Voice; | |
echo $lang->loud("PHP"); |
This file contains 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
(ns my.best$macros) | |
(defmacro defprint1 [func-name args & body] | |
`(defn ~func-name [& args#] | |
(print '~func-name "called with: " args#) | |
(let [~args args#] | |
~@body))) | |
(defmacro defprint2 | |
[name args & body] |
This file contains 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 concurrent prime sieve | |
package main | |
import "fmt" | |
// Send the sequence 2, 3, 4, ... to channel 'ch'. | |
func Generate(ch chan<- int) { | |
for i := 2; ; i++ { | |
ch <- i // Send 'i' to channel 'ch'. |
This file contains 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 v [x] | |
(list 'λ x)) | |
(defn view [n] ((n v) 'x)) | |
(deftype LambdaNum [n] | |
Object | |
(toString [this] (str (view this))) | |
(equiv [this other] (-equiv this other)) | |
This file contains 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 visual [x] | |
(list 'f x)) | |
(defn view [f] | |
((f visual) 'x)) | |
(deftype Lambda [f] | |
Object | |
(toString [_] (str (view f))) |