Skip to content

Instantly share code, notes, and snippets.

@telephon
telephon / gist:0e31961dfd1599ddc3ce4e158e6e3dcb
Created May 25, 2024 12:51
delegation test for doesNotUnderstand / doesNotUnderstandAbout
SuperKlasse {
// this is the interface in Object
// if an object does not understand,
// we look which of the two the class implements,
// and call the appropriate one.
doesNotUnderstand { |selector ... args|
"I am the super class, doesNotUnderstand. I have received the following arguments:\n%\n%\n".format(selector, args).postln;
"I'll forward to doesNotUnderstandAbout".postln;
@telephon
telephon / flop-event.scd
Last active November 7, 2017 07:18
completely flopping dictionaries might be more efficient after all
(
var flop = { |dict, keys|
var values, size;
keys = keys ?? { dict.keys.asArray }; // in terms of performance, this is the main bottleneck
values = keys.collect { |x| dict.at(x) }; // and this.
values = values.flop:
size = values.first.size;
values.collect { |xs|
var each = dict.copy;
@telephon
telephon / dice-unicode
Last active November 6, 2017 11:59
unicode test for scide
these should be dice: ⚂⚁
if not, there is something wrong with you.
@telephon
telephon / stitching functions
Last active July 6, 2017 19:58
These functions are possible ways of stitching one array into another. This models variants of a possible future Pbindef behaviour
// the groups of inserted items are kept as arrays for easier reading
// eventually we use something like the insertAll function to embed them instead
(
var insertAll;
insertAll = { |i, list, insertedList|
j = (i - 1).clip(0, list.size - 1);
list[0..j] ++ insertedList ++ list[j+1..]
};