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
secret_number gets between: 1 10 | |
3 times | |
write: Choose a number from 1 to 10. | |
my_number gets ask: > | |
if my_number is @secret_number | |
write: You win! The number was @secret_number. | |
quit | |
else |
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
#include <stdio.h> | |
int main() <% | |
int x <:3] = {1, 2, 3%>; | |
printf("%d, %d, %d\n", x[0:>, x<:1], x<:2:>); | |
return 0; | |
} |
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
var myObj = (function() { | |
function myObj(something) { | |
this.something = something; | |
} | |
function privateMethod() { | |
console.log("private method called"); | |
} | |
myObj.prototype.publicMethod = function() { |
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 templating(template, values) { | |
for(var k in values) { | |
template = template.replace('{{' + k.toString() + '}}', values[k].toString()); | |
} | |
return template; | |
} |
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
(define (templating template values) | |
(hash:keys-reduce (lambda (template k) (string:substitute template (++ "{{" k "}}") (values k))) template values)) |
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
;; Solution to: | |
;; How many different ways can we make change of $ 1.00, given half-dollars, quarters, dimes, nickels, and pennies? | |
;; More generally, can we write a procedure to compute the number of ways to change any given amount of money? | |
;; | |
;; Example usage for $1.00: (count-change 100) => 292 | |
;; This computation takes around 0.6 secs on my machine in zepto. | |
(define (count-change amount) | |
(cc amount 5)) |
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
Array.prototype.next = function(i) { | |
return this[++i % this.length]; | |
} | |
Array.prototype.previous = function(i) { | |
return i === 0 ? this[this.length - 1] : this[--i % this.length]; | |
} |
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
; Sneak this in somewhere | |
(defmacro = [& args] (apply (rand-nth [identical? not=]) args)) |
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
(system-include "../bench.h") | |
(register get-time-elapsed (Fn [] Double)) | |
(defn min [a] | |
(let [m (Double.copy (Array.nth a 0))] | |
(do | |
(for [i 1 (Array.count a)] | |
(let [el (Double.copy (Array.nth a i))] | |
(if (Double.< el m) |
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
#include <string.h> | |
#include <stdlib.h> | |
#include <core.h> | |
static const char base64_table[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
String b64(String* osrc) { | |
String src = *osrc; | |
int len = strlen(src); | |
char *pos; |
OlderNewer