This file contains hidden or 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
number = 1 | |
#creates the nth triangle number | |
def triangle(number): | |
return (number * (number + 1)) / 2 | |
#finds factors for triangle numbers | |
def factors(number): | |
num_factors = 0 | |
for i in xrange(1, int(number**0.5) + 1): |
This file contains hidden or 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
ORG $400 | |
LEA STRING,A1 a1 points to mem to be printed | |
MOVE.B #14,D0 d0 holds our trap code | |
TRAP #15 print from a1 | |
LEA SPACE,A1 point a1 to space | |
TRAP #15 print space | |
MOVEA.L #DATA,A0 point a0 at our data list | |
This file contains hidden or 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
require "irc" | |
local lanes = require "lanes".configure() | |
local linda = lanes.linda() | |
local re = require "re" | |
local sleep = require "socket".sleep | |
local id = 0 | |
local queued_requests = {} |
This file contains hidden or 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
a = bin(999999999)[2:] | |
temp = [] | |
for i, v in enumerate(a): | |
if v == '1': | |
temp.append(len(a) - i) | |
print a | |
print temp | |
# 111011100110101100100111111111 | |
# [30, 29, 28, 26, 25, 24, 21, 20, 18, 16, 15, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1] |
This file contains hidden or 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
use std::os; | |
enum Token { | |
Add, | |
Sub, | |
Mul, | |
Div, | |
Mod, | |
Func {name: ~str, args: ~[~str]}, | |
Num (int), |
This file contains hidden or 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
use std::uint; | |
use std::io; | |
use std::str; | |
enum Token { | |
Add, | |
Sub, | |
Inc, | |
Dec, | |
Out, |
This file contains hidden or 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
#[deriving(Clone)] | |
enum List<T> { | |
Empty, | |
Cons(T, ~List<T>) | |
} | |
impl<T: Eq + Clone> List <T> { | |
fn map(&self, f: &fn(T)->T)->List<T>{ | |
match *self { | |
Empty => Empty, | |
Cons(ref x, ref xs) => Cons(f(x.clone()),~xs.map(f)) |
This file contains hidden or 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
use std::fmt; | |
use std::io::net::tcp::TcpStream; | |
use std::io::net::ip::{Ipv4Addr, SocketAddr}; | |
use std::io::buffered::BufferedStream; | |
#[deriving(Clone)] | |
pub struct RustBot { | |
nick: ~str, | |
user: ~str, | |
stream: BufferedStream<TcpStream>, |
This file contains hidden or 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
use std::run::{Process, ProcessOptions}; | |
struct Gdb { | |
process: Process, | |
} | |
impl Gdb { | |
fn new(debuggee: ~str) -> Gdb { | |
let args = [~"gdb", ~"--return-child-result", ~"--quiet", ~"--nx", |
This file contains hidden or 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
pub fn h(x: ||) { x() } |