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
using System; | |
using System.Collections.Generic; | |
namespace Bounce | |
{ | |
public class UnitCircle | |
{ | |
public UnitCircle() | |
{ | |
pi = Math.PI; |
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
for (int i = 0; i < PhysicalSprites.Count; i++) | |
{ | |
if (PhysicalSprites[i].IsAlive) | |
PhysicalSprites[i].Update(gameTime); | |
else | |
{ | |
PhysicalSprites[i].Body.Dispose(); | |
PhysicalSprites.RemoveAt(i); | |
i--; | |
} |
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
public static List<Body> CreateFraming(World world, int width) | |
{ | |
List<Body> bodyList = new List<Body>(); | |
float x = WindowSize.X; | |
float y = WindowSize.Y; | |
for (float i = 0f; i <= x; i += x) | |
{ | |
for (float j = 0f; j <= y; j += y) | |
{ |
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
import Data.List | |
import System.Environment | |
isPythTriplet :: (Integer, Integer, Integer) -> Bool | |
isPythTriplet (a, b, c) = (a^2) + (b^2) == (c^2) | |
-- All possible representations of three elements from xs, | |
-- where let xs[x] = indexof x in xs[a] < xs[b] < xs[c]. | |
triplets :: [Integer] -> [(Integer, Integer, Integer)] | |
triplets xs = [ (a, b, c) | a:as <- tails xs, |
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 membersOfType(o, *types): | |
return dict( | |
[(m, a) | |
for m, a in map(lambda x: (x, getattr(o, x)), dir(o)) | |
if any([isinstance(a, t) for t in types])]) |
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::toSet = -> | |
s = {} | |
s[x] = i for x,i in @ | |
@[v] for k,v of s |
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
public class Primes { | |
public static void main(String[] args) { | |
//Print the primes up to 107. | |
for (Integer p : new RPrimeSieve(107)) | |
System.out.println(p); | |
} | |
} |
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
randomBirthdays = (n) -> | |
r = {} | |
for i in [1..n] | |
r[Math.floor Math.random() * 364 + 1] = true | |
k for k,v of r | |
do -> | |
n = 23; sum = 0 | |
for i in [0..Math.pow 10, 4] | |
if n != (randomBirthdays n).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
//Correct way: | |
window.setInterval(function() { | |
$.get("/minus/new?folderurl=" + $("#folderurl").val(), function(data) { | |
$("#progress").html(data); | |
}) | |
}, 1000); | |
//You had this: | |
window.setInterval($.get("/minus/new?folderurl=" + $("#folderurl").val(), function(data) { |
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
qsort1 :: Ord a => [a] -> [a] | |
qsort1 [] = [] | |
qsort1 (p:xs) = qsort1 lesser ++ [p] ++ qsort1 greater | |
where | |
lesser = filter (< p) xs | |
greater = filter (>= p) xs |
OlderNewer