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"))) |
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
""" | |
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
\ 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
import os | |
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget | |
from IPython.qt.manager import QtKernelManager | |
from IPython.qt.inprocess import QtInProcessKernelManager | |
from IPython.kernel.zmq.ipkernel import Kernel | |
from IPython.kernel.inprocess.ipkernel import InProcessKernel | |
from IPython.lib import guisupport | |
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
U+1f601 π | |
U+1f602 π | |
U+1f603 π | |
U+1f604 π | |
U+1f605 π | |
U+1f606 π | |
U+1f607 π | |
U+1f608 π | |
U+1f609 π | |
U+1f60a π |
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
#class extensions a la Objective-C "categories" | |
#using metaclasses | |
excluded_methods = frozenset(["__module__", "__qualname__"]) | |
def class_extend(cls): | |
class Meta(type): | |
def __new__(self, name, bases, attrs, **kwargs): | |
for name, value in attrs.items(): | |
if name not in excluded_methods: |
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
iab AE\ Γ | |
iab Alpha\ Ξ | |
iab Angle\ β¦ | |
iab Beta\ Ξ | |
iab Bumpeq\ β | |
iab Cap\ β | |
iab Chi\ Ξ§ | |
iab Colon\ β· | |
iab Cup\ β | |
iab DH\ Γ |
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
""" | |
Support `fake` binary operator | |
so we can do | |
a @f@ b | |
in addition to (and with the same meaning as): | |
f(a, b) | |
""" | |
import collections.abc |
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
from functools import lru_cache | |
def identity(x): | |
return x | |
@lru_cache(None) | |
def _make_compose(n): | |
if n == 0: | |
return lambda: identity | |
elif n == 1: |
OlderNewer