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
\ Computing mean and population standard deviation in Forth. | |
\ Tested on Gforth 0.7.0 | |
16 constant FRAC \ number of bits behind fixed-point | |
\ convert from/to fixed point representation | |
: s>fix FRAC lshift ; | |
: fix>s FRAC rshift ; | |
\ fixed-point arithmetic |
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
""" | |
Utility functions for hex grids. | |
""" | |
from math import sqrt | |
from heapq import heappush, heappop | |
import numpy | |
import numpy.random | |
neighbours = numpy.array(((2, 0), (1, 1), (-1, 1), (-2, 0), (-1, -1), (1, -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
package libscratch | |
object `package` { | |
def floorDiv(p : Int, q : Int) : Int = | |
if (p < 0) { | |
if (q < 0) { | |
p / q | |
} else { | |
(p - q + 1) / q |
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
#lang racket | |
(require 2htdp/image | |
(only-in mred make-bitmap bitmap-dc%) | |
(only-in 2htdp/private/image-more render-image) | |
rackunit) | |
(define star1 (star-polygon 40 5 2 "solid" "seagreen")) | |
(define star2 (rotate 20 (star-polygon 40 5 2 "solid" "seagreen"))) |
NewerOlder