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
1000 Kittens | |
Abandoned | |
Afterlife | |
Beginning of Time | |
Break the Rules | |
Castles | |
Chain Reaction | |
Colony | |
Companion | |
Creation and Destruction |
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
-- Collision detection function. | |
-- Checks if box1 and box2 overlap. | |
-- w and h mean width and height. | |
-- From the love wiki http://love2d.org/wiki/BoundingBox.lua | |
function CheckCollision(box1x, box1y, box1w, box1h, box2x, box2y, box2w, box2h) | |
if box1x > box2x + box2w - 1 or -- Is box1 on the right side of box2? | |
box1y > box2y + box2h - 1 or -- Is box1 under box2? | |
box2x > box1x + box1w - 1 or -- Is box2 on the right side of box1? | |
box2y > box1y + box1h - 1 -- Is b2 under b1? | |
then |
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 <iostream> | |
// This file is kind of crazy because of the names, but here goes... | |
// Foo is our template class. It holds a thing of type T, called the_t. | |
// When someone creates a new Foo, it creates a T with T::T() and saves it. | |
// Then, someone can call Foo.foobar and pass us an "uber" of type U. | |
// The uber needs to have a spork function, which accepts a T. | |
// the type signature looks like this: | |
// void U::spork(T); |
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
(defmacro with-lines (line-sym path &rest body) | |
(let ((f-sym (gensym))) | |
`(with-open-file (,f-sym ,path) | |
(do ((,line-sym (read-line ,f-sym nil) | |
(read-line ,f-sym nil))) | |
((null ,line-sym)) | |
,@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
-- Euler 14 | |
-- Collatz #s | |
with ada.text_io; | |
use ada.text_io; | |
procedure e14 is | |
package int_io is new ada.text_io.integer_io(integer); | |
use int_io; |
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
-- Euler 26 | |
with ada.text_io; | |
use ada.text_io; | |
with ada.containers.doubly_linked_lists; | |
procedure e26_tasked is | |
package int_list is new ada.containers.doubly_linked_lists(integer); |
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
local function tokenize(program) | |
program = string.gsub(program, "%-%-.-\n", "\n"); | |
program = string.gsub(program, "(%g+);", "%1 ;"); | |
coroutine.yield() | |
for token in string.gmatch(program, "[a-z0-9_:;]+") do | |
coroutine.yield(token) | |
end | |
return nil | |
end |
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
-- Euler 14 | |
-- Collatz #s | |
with ada.text_io; | |
use ada.text_io; | |
procedure e14 is | |
package int_io is new ada.text_io.integer_io(integer); | |
use int_io; |
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
(defun generate-typecode (name arg-types return-type defn) | |
(push (list name (types-from-arglist arg-types) return-type) | |
*type-registry*) | |
`(let ((localtypes nil)) | |
,(loop for (type argname) in (pairs arg-types) | |
collect `(push (cons ,argname ,type) localtypes)) | |
,(loop for (fname &rest args) in defn | |
collect (cond | |
((keywordp fname) (generate-type-assertion fname args)) | |
(t 't))))) |
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
; Euler 1 | |
(defun divides (x y) | |
(zerop (mod y x))) | |
(defun sum (l) | |
(reduce #'+ l)) | |
(defun range (a b) | |
(loop for i from a to b collecting i)) |
OlderNewer