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
package com.thomcc.nine.level.gen; | |
import java.awt.Image; | |
import java.awt.geom.Point2D; | |
import java.awt.image.BufferedImage; | |
import java.awt.image.DataBufferInt; | |
import java.util.ArrayList; | |
import java.util.Random; | |
import javax.swing.ImageIcon; |
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
### Reverse Polish Notation (postfix) Calculator | |
class RPNCalculator | |
attr_accessor :stack | |
def initialize | |
# the stack, which will contain all the numbers this calculator | |
# can perform operations on | |
@stack = [] | |
# the operations which this calculator supports. we store them as | |
# a hashtable which maps the symbol the user enters to a lambda of | |
# two values. |
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 chatty.core | |
(:import [java.net DatagramPacket InetAddress DatagramSocket])) | |
(defn send-data [socket ip port data] | |
(let [ipaddr (InetAddress/getByName ip) | |
pkt (DatagramPacket. (.getBytes data) (count data) ipaddr port)] | |
(.send socket pkt))) | |
(defn receive-data [socket] | |
(let [data (byte-array 1024), pkt (DatagramPacket. data 1024)] |
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
#lang racket | |
;; -*- geiser-scheme-implementation: racket -*- | |
(require "utils.rkt") | |
;(provide struct:bitmap bitmap-width bitmap-height bitmap? make-bitmap bitmap-dimensions) | |
(provide (all-defined-out)) | |
(struct bitmap (width height data) #:transparent | |
#:guard | |
(λ (w h d type) | |
(if (and (= (vector-length d) h) |
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 clorth.core | |
(:require clojure.pprint)) | |
(defn defword* | |
([dict word code] (defword* dict word code false)) | |
([dict word code immediate] | |
(assoc dict word {:name word, :code code, :immediate immediate}))) | |
(defmacro defword [dict name vars & code] | |
`(defword* ~dict (keyword '~name) |
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
(defn splitup [ls] | |
(loop [rest ls, evens [], odds []] | |
(if-not rest | |
[evens odds] | |
(recur (nnext rest) | |
(conj evens (first rest)) | |
(if (fnext rest) | |
(conj odds (fnext rest)) | |
odds))))) |
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
#lang racket/gui | |
(define (floor* n [v 1.0]) | |
(inexact->exact (floor (/ n v)))) | |
(define (offset n v) | |
(+ n (- (random v) (random v)))) | |
(define (take-average lst) | |
(let ([n (exact->inexact (length lst))]) | |
(for/sum ([e (in-list lst)]) (/ e n)))) |
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
package com.thomcc.nine.render; | |
import java.awt.Image; | |
import java.awt.image.BufferedImage; | |
import java.awt.image.DataBufferInt; | |
import javax.swing.ImageIcon; | |
import javax.swing.JOptionPane; | |
public class Radar { |
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
(statements | |
(compile | |
'((define (factorial n) | |
(if (= n 0) | |
1 | |
(* n (factorial (- n 1))))) | |
(factorial 1000)) | |
'val | |
'return)) | |
; => |
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
x = [ | |
%q{puts "x = ["}, | |
%q{x.each_with_index {|s,i| puts "%q{" << s << "}" << (i == x.length-1 ? "" : ",") }}, | |
%q{puts "]"}, | |
%q{puts "x.map {|s| eval s}"} | |
] | |
x.map {|s| eval s} |