Skip to content

Instantly share code, notes, and snippets.

View timsgardner's full-sized avatar

Tims Gardner timsgardner

  • Arcadia Technologies
  • Brooklyn, NY
View GitHub Profile
@timsgardner
timsgardner / splice-into.clj
Created January 28, 2016 18:24
splice into, with transducer cat
(defn splice-into [v n xs]
(into (subvec v 0 n) cat [xs (subvec v n)]))
(ns cloze.traversal)
;; ============================================================
;; traverser
(defprotocol ITraverser
(branch? [this x])
(children [this x])
(make-node [this x kids]))
using UnityEngine;
[System.Serializable]
public class HelixMaterialSpec : UnityEngine.Object
{
public Vector2 arcStartPoint = new Vector2(0, 1);
public Vector2 arcStopPoint = new Vector2(1, 0);
public float arcOuterRadius = 1F;
public Material material = null;
public static float[] subdivArray(float n, float div){
float flr = Mathf.Floor(n / div);
float rem = Mathf.Mod(n, div);
r = Enumerable.Range(0, flr).Select(i => i * div);
if(rem == 0){
return r.ToArray;
}else{
return r.Concat(new float[]{rem}).ToArray;
}
}
;; works
(-> [[1 0] [1 0]]
(System.Linq.Enumerable/SelectMany identity)
vec)
;; doesn't
(-> [[1 0] [1 0]]
(System.Linq.Enumerable/SelectMany identity)
(System.Linq.Enumerable/Distinct (type-args System.Linq.Enumerable))
vec)
using Cubiquity;
public class CubiquityHelper{
public static void stupidTest(uint n){
bool[] ar = new bool[1];
for(int i = 0; i < n; i++){
ar[0] = true;
}
using clojure.lang;
using System;
[Serializable]
public class clojure_west/stupid_idea$volatile_fun_test$fn__499__503 : AFunction
{
//
// Static Fields
//
protected internal static object const__0;
(defmacro swiz [v spec]
(let [spec (name spec)
op (case (count spec)
2 'v2
3 'v3
4 'v4)
vsym (gensym "v_")]
`(let [~vsym ~v]
(~op ~@(map #(list '. vsym (symbol (str %))) spec)))))
(defn over-color ^Color [^Color a
^Color b]
(let [^Vector4 a (v4 (.r a) (.g a) (.b a) (.a a))
^Vector4 b (v4 (.r b) (.g b) (.b b) (.a b))
c (Vector4/op_Addition
(Vector4/op_Multiply a (float (.w a)))
(Vector4/op_Multiply
(Vector4/op_Multiply b (float (.w b)))
(- 1 (.w a))))
blend (+ (.w a)
@timsgardner
timsgardner / comp-pro .clj
Last active September 12, 2015 09:07
comp-pro
(defmacro ^:private defn-meval [& preamble-and-meval-to-forms]
(let [preamble (butlast preamble-and-meval-to-forms)
meval-to-forms (last preamble-and-meval-to-forms)
mevaluated (eval meval-to-forms)]
`(defn ~@preamble
~@mevaluated)))
(defn-meval comp-pro
(let [fargs (repeatedly gensym)
xarg (gensym "xarg")]