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 Turtle { | |
constructor(ox, oy, ctx) { | |
this.ctx = ctx; | |
this.ox = ox; | |
this.oy = oy; | |
this.reset(); | |
} | |
reset() { | |
this.x = this.ox; |
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
(defconstant target "ME THINKS IT IS LIKE A WEASEL") | |
(defun rand-letter () | |
(let ((r (random 27))) | |
(if (= r 26) | |
#\space | |
(code-char (+ (char-code #\A) r))))) | |
(defun rand-string (n) | |
(coerce (loop for i from 1 to 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
#lang racket | |
(define (arity f) | |
(let ([a (procedure-arity f)]) | |
(if (number? a) | |
a | |
#f))) | |
(define (comp f g) |
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 socket | |
import time | |
import re | |
import os | |
import sys | |
HOST = sys.argv[1] | |
PORT = int(sys.argv[2]) |
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
use strict; | |
use warnings; | |
use IO::Socket; | |
sub handle { | |
my $c = shift; | |
my $command = <$c>; | |
$command = "" unless $command; | |
chomp $command; |
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 get_next_token(s): | |
while s and s[0].isspace(): | |
s = s[1:] | |
if not s: | |
return None, "" | |
if s[0] in "()": | |
return s[0], s[1:] | |
i = 0 | |
while i < len(s) and not s[i].isspace() and s[i] not in "()": | |
i += 1 |
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 | |
(require plot) | |
(define (sigmoid x) | |
(/ 1.0 (+ 1 (exp (- x))))) | |
(define (step x) | |
(if (>= x 0) 1 0)) |
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.util.Random | |
class Perceptron(weights: Array[Double], learningRate: Double = 0.01, bias: Double = 1.0) { | |
def fit(input: Array[Array[Double]], labels: Array[Double]): Array[Double] = | |
fitWithBias(input, labels) | |
def fitWithBias(data: Array[Array[Double]], labels: Array[Double], epochs: Int = 1000): Array[Double] = | |
train(addBias(data), labels, epochs) | |
def train(data: Array[Array[Double]], labels: Array[Double], epochs: Int): Array[Double] = |
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
(defclass seq () ()) | |
(defmethod s-first ((s seq)) | |
"The first element, if exists" | |
(error "Implement in child class")) | |
(defmethod s-rest ((s seq)) | |
"The rest of the sequence, if exists" | |
(error "Implement in child class")) |
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 Console1 | |
{ | |
class Beverage | |
{} | |
class Flavor | |
{} |
NewerOlder