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
Copyright (c)2011, Enrico Franchi | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
* Redistributions of source code must retain the above copyright | |
notice, this list of conditions and the following disclaimer. |
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
_AtkinSieve.AddNumbers%i4%o<AtkinSieve>i4i4: | |
0007f688 pushl %ebp | |
0007f689 movl %esp,%ebp | |
0007f68b subl $0x00000038,%esp | |
0007f691 movl %esp,0xffffffcc(%ebp) | |
0007f697 movl %ebp,%eax | |
0007f699 movl 0x08(%eax),%eax | |
0007f69c movl %eax,0xf8(%ebp) | |
0007f69f movl %ebp,%eax | |
0007f6a1 movl 0x0c(%eax),%eax |
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 java.lang.Boolean; | |
import java.lang.Integer; | |
public class AtkinSieveArray { | |
static private int count(boolean[] buffer) { | |
int counter = 0; | |
for(int i = 2; i < buffer.length; ++i) { | |
if(buffer[i]) { | |
counter++; |
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 atkin(buffer, end): | |
limit = int(math.ceil(math.sqrt(end))) | |
for x in range(1, limit + 1): | |
x2 = x * x | |
x2_3 = 3 * x2 | |
for y in range(1, limit + 1): | |
y2 = y * 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
class AdjacencyListGraph(object): | |
def __init__(self): | |
self.node = {} | |
self.adj = {} | |
def add_node(self, node, **attrs): | |
if node not in self.adj: | |
self.adj[node] = {} | |
self.node[node] = attrs |
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 gui-sample | |
(:import [javax.swing JFrame JButton] | |
[java.awt.event ActionListener])) | |
(defn build-gui [title message] | |
(let [frame (JFrame. title) | |
button (JButton. "CLICK")] | |
(.addActionListener button | |
(proxy [ActionListener] [] | |
(actionPerformed [evt] |
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 example.ClassExample | |
(:gen-class | |
:name example.ClassExample | |
:extends Object | |
:implements [] | |
:methods [[foo [java.util.Collection] int] | |
^{:static true} [show [java.util.Collection] void]]) | |
(:import (java.util Collection))) | |
(defn -foo [this coll] |
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 re | |
import os | |
import ast | |
import glob | |
import collections | |
class ImportVisitor(ast.NodeVisitor): | |
def __init__(self): | |
self.imports = [] | |
self.modules = collections.defaultdict(list) |
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 sys | |
class TextualUI(object): | |
def __init__(self, out=sys.stdout): | |
self.out = out | |
def inform_defeat(self, _max_attempts): | |
message = 'You lost.\n' | |
self.out.write(message) |
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
(defproject AgentNetSym "1.0.0-SNAPSHOT" | |
:description "FIXME: write" | |
:dependencies [[org.clojure/clojure "1.2.0"] | |
[org.clojure/clojure-contrib "1.2.0"] | |
[net.sourceforge.collections/collections-generic "4.01"] | |
[com.cedarsoft.serialization/stax "2.1.0"] | |
[java3d/vecmath "1.3.1"] | |
[org.codehaus.woodstox/wstx-asl "3.2.9"] | |
[colt/colt "1.2.0"] |