Skip to content

Instantly share code, notes, and snippets.

create name !A!b=1, animate me . 1 1 0; at tm A:=0 100, name !A!b=1; at tm A:=1 101, name !A!b=0; at tm B:=0 102, animate me . 1 1 0; at tm B:=1 103, animate me . 1 1 1000000000; at tm A*B 104, astart !A!b=1; adone timer !A&!B=1 200 reset
create name !Ab=1; at tm A:=0 100, name !Ab=1; at tm A:=1 101, name !Ab=0; at tm B:=0 102, animate me . 1 1 1000000000; at tm B:=1 103, animate me . 1 1 0; at tm A*B 104, astart !Ab=1; adone timer !A&B=1 200 reset
create name Ab=0; at tm A:=0 100, name Ab=0 ; at tm A:=1 101, name Ab=1; at tm B:=0 102, animate me . 1 1 1000000000; at tm B:=1 103, animate me . 1 1 0; at tm A*B 104, astart Ab=1; adone timer A&B=1 200 reset
create animate me . 1 1 0, name A!b=0; at tm A:=0 100, name A!b=0; at tm A:=1 101, name A!b=1; at tm B:=0 102, animate me . 1 1 0; at tm B:=1 103, animate me . 1 1 1000000000; at tm A*B 104, astart A!b=1; adone timer A&!B=1 200 reset
at tm A&B=1 100, timer A&!B=0 200 reset, timer !A&B=0 200 reset, timer !A&!B=0 200 reset, timer A=1 200 reset, timer B=1 200 re
@Sgeo
Sgeo / quantum_rounding.lsl
Created November 12, 2015 05:40
Measures the impact of floating point numbers on low velocities
float estimated_min_attempt_vel(float fps)
{
vector pos = llGetPos();
float alt = pos.z;
integer shell = llFloor(llLog(alt)/llLog(2.0));
return fps * llPow(2.0, (float)shell - 24.0);
}
show(float attempting, float getvel, float actual, float fps, float dilation)
{
DynamicVariable subclass: #DynamicGeneratorVar
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Sgeo-DynamicGenerator'!
!DynamicGeneratorVar commentStamp: 'SethJGold 1/14/2013 06:41' prior: 0!
DynamicGeneratorVar holds the current DynamicGenerator in use. Should not be used directly by client code.!
waitFor: anAnnouncementClass
"Blocks the current process until anAnnouncementClass is announced.
Note that synchronous code using this method runs the risk of missing announcements."
| val sem |
sem := Semaphore new.
self on: anAnnouncementClass do: [:ann | val := ann. sem signal].
sem wait.
^val.
@Sgeo
Sgeo / gist:4717537
Created February 5, 2013 20:52
Haskell code to emulate in Scala and Clojure. Idea for the functions taken from http://www.scala-lang.org/api/current/index.html#scala.util.control.TailCalls$
listEven :: [a] -> Bool
listEven [] = True
listEven (_:xs) = listOdd xs
listOdd :: [a] -> Bool
listOdd [] = False
listOdd (_:xs) = listEven xs
@Sgeo
Sgeo / gist:4717756
Created February 5, 2013 21:20
Demonstration of mutually recursive tail-call optimized functions in Scala.
/* code taken verbatim from http://www.scala-lang.org/api/current/index.html#scala.util.control.TailCalls$ */
def isEven(xs: List[Int]): TailRec[Boolean] =
if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail))
def isOdd(xs: List[Int]): TailRec[Boolean] =
if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail))
REBOL [
Title: "Monads"
Author: "Sgeo"
]
do-monad: func [
monad "An object containing a /bind and a /return."
assigns [block!]
result [block!]
/local ma f next-assigns arg
use [num] [
num: 0
count: func [x] [
num: num + x
print num
]
]
count 1 count 1 count 1
@Sgeo
Sgeo / hsum.rs
Last active February 11, 2016 02:01
Anonymous sum type prototype
use std::marker::PhantomData;
pub enum Void {}
impl Void {
fn any(&self) -> ! {
match *self {}
}
}
use std::rc::{Rc, Weak};
use std::cell::RefCell;
pub struct Scope<'t, T: 't> {
filled: bool,
hole: &'t mut T
}
impl<'t, T: 't> Scope<'t, T> {
unsafe fn new(mut_ref: &'t mut T) -> (T, Self) {