Skip to content

Instantly share code, notes, and snippets.

sub needs-change($o) { $o->name eq 'Seek' }
sub change($o) {
my %props = %o{qw/name level x y/};
my @perks = @$o->perks;
push @perks, $perk_to_add;
%props{perks} = \@perks;
bless %props, ref($o);
}
my @updated = map { needs-change($_) ? change($_) : $_ } @objects;
(def tree
{:nodes
[
{:function "start"
:nodes [{:call "end" :nodes [{:call "middle"}]}]
}
{:function "middle"
:nodes [{:call "start"} {:call "end"}]}
{:function "end"
:nodes [{:call "start"}]}
type Tuple<A, B> = [A, B];
function extractErr<E, R>(r: Result<E, R>): E | undefined {
return r.type === "error" ? r.value : undefined;
}
function composeR<E1, E2, R1, R2>(
r1: Result<E1, R1>,
r2: Result<E2, R2>
): Result<Tuple<E1 | undefined, E2 | undefined>, Tuple<R1, R2>> {
if (r1.type === "error" || r2.type === "error")
return err([extractErr(r1), extractErr(r2)]);
def s [match?: string] {
if ($match == null) {
git rev-parse --abbrev-ref HEAD | str trim
} else {
let $branches = git branch | grep -i $match | tr '*' ' ' | lines | str trim
let $length = $branches | length
if ($length == 0) {
"No branch found with hint"
} else if ($length == 1) {
git checkout $branches.0
Scorpio "SmallBuff" "0.1"
import "System.Reactive"
local _Cache = {}
local function GetSpellFromCache(id)
if not _Cache[id] then
local name, _, icon = GetSpellInfo(id)
_Cache[id] = { name = name, icon = icon }
end
@vendethiel
vendethiel / once.js
Last active March 31, 2022 12:18
Once
const once = (function () {
const fns = [];
let i = 0;
return function (fn) {
const cur = i++;
fns[cur] = fn;
return function () {
if (fns[cur]) {
fns[cur].apply(null, arguments);
fns[cur] = null;
import Control.Monad
import Control.Monad.State
import Data.Sequence as Seq
import Data.Foldable (toList)
import Debug.Trace
import Data.Maybe
import Text.Printf
data Direction = East | South | West | North
nextDirection :: Direction -> Direction
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class Test
{
public class Parser
{
private string _text;
private string _error;
using System;
using System.Collections.Generic;
namespace FauxCombinator
{
public abstract class Parser<T>
{
protected (T, string) parseSeparatedBy(string text, string sep, Func<string, (T, string)> subparse, Func<List<T>, T> ctor)
{
var nodes = new List<T>();
package.path = package.path .. ";../?/init.lua;../?.lua"
require "PLoop"(function (_ENV)
class "__State_Machine__" (function(_ENV)
extend "IApplyAttribute"
function ApplyAttribute(self, target, targettype, manager, owner, name, stack)
if manager then
Environment.Apply(manager, function(_ENV)
property "State" { default = self.State }