Skip to content

Instantly share code, notes, and snippets.

View allison-casey's full-sized avatar
🤗

Allie Jo Casey allison-casey

🤗
  • Firsthand
  • California
View GitHub Profile
public static A reduce<T, A>(Func<A, T, A> fn, A accum, T[] iterable) {
int idx = 0;
int len = iterable.Length;
while(idx < len) {
accum = fn(accum, iterable[idx]);
idx += 1;
}
return accum;
---
definitions:
effect:
type: object
properties:
id:
oneOf:
- type: integer
- type: string
name:
@allison-casey
allison-casey / blob.clj
Created December 9, 2019 21:56
bitmasking
(ns playground.bitmasking.blob
(:require [playground.bitmasking.utils
:refer [index->coord coord->index reshape2d->1d]]))
(defn ^:private calc-offsets
[x y]
(let [north [x (dec y)]
north-east [(inc x) (dec y)]
east [(inc x) y]
south-east [(inc x) (inc y)]
;; EFFECTS
{:type :constant
:target "%.aim"
:operator :add
:value 5}
{:type :expression
:target "%.mobility"
:operator :add
:expression "%.mobility * 0.2"}
;; EFFECTS
;; effects are the fundamentall building block of the engine. they provide a means of interacting with entities and changing their state. they should be as mini.al as possible, leaving the method of their application to higher order elements.
{:type :constant
:target "%.aim"
:operator :add
:value 5}
{:type :expression
:target "%.mobility"
(import [pyparsing :as pp])
(with [f (open "config.cpp")]
(setv config (.readlines f)))
(setv colon ":"
open-curly "{"
klass (pp.CaselessKeyword "class")
klass-name ((pp.Word (+ pp.alphanums "_")) "class_name")
base-klass ((pp.Word (+ pp.alphanums "_")) "base_class")
( hint "hello world" );
private _is_odd =
{
params ["_x"];
((_x % 2) != 0)
};
private _is_even =
{
params ["_x"];
((_x % 2) == 0)
( hint "hello world" );
private _is_odd =
{
params ["_x"];
((_x % 2) != 0)
};
private _is_even =
{
params ["_x"];
((_x % 2) == 0)
;; stdlib
(defglobal odd? [x] (!= (% x 2) 0))
(defglobal even? [x] (= (% x 2) 0))
(defglobal list? [x] (= (typeName x) "ARRAY"))
(defglobal string? [x] (= (typeName x) "STRING"))
(defglobal number? [x] (= (typeName x) "SCALAR"))
(defglobal bool? [x] (= (typeName x) "BOOL"))
(defglobal int? [x] (= (floor x) x))
(defglobal pos? [x] (> x 0))
(defglobal neg? [x] (< x 0))
(defn sqisp-repr [obj]
(cond
(set? obj) (format ["#{%1}" (joinString (map sqisp-repr (iter-items obj)) ", ")])
(map? obj) (format ["{%1}"
(joinString
(map (fn [x]
(joinString [(sqisp-repr (first x))
(sqisp-repr (second x))]
" "))
(iter-items obj)) ", ")])