Skip to content

Instantly share code, notes, and snippets.

View tk3369's full-sized avatar
🐶
Published! Hands on design patterns and best practices with Julia.

Tom Kwong tk3369

🐶
Published! Hands on design patterns and best practices with Julia.
View GitHub Profile
"""
Print a subtype tree from the specified `roottype`
"""
function subtypetree(roottype, level=1, indent=4)
level == 1 && println(roottype)
for s in subtypes(roottype)
println(join(fill(" ", level * indent)) * string(s))
subtypetree(s, level+1, indent)
end
end
// Estimate PI using monte carlo simulation
// See http://www.davidrobles.net/blog/2014/06/22/estimating-pi-using-monte-carlo-simulations/
import 'dart:math';
Random rnd = new Random();
// Return a random point within [-1, 1] coordinate plane
class UnitPoint {
double x;
@tk3369
tk3369 / fizzbuzz_no_if.swift
Created February 1, 2015 23:04
FizzBuzz in Swift without if-statement
for i in 1...100 {
println([["FizzBuzz","Fizz"],["Buzz","\(i)"]][min(1,i%3)][min(1,i%5)])
}