Skip to content

Instantly share code, notes, and snippets.

@jack-williams
jack-williams / List
Last active June 15, 2023 09:35
Excel list functions
/**
* Tests whether the input is a list.
* A list is an array with one row or column.
*/
isList = LAMBDA(input, AND(TYPE(input) = 64, OR(ROWS(input) = 1, COLUMNS(input) = 1)));
/**
* Applies an array-returning function to each element of the input list,
* returning a flattened array. The result are arranged vertically.
* ```
@jack-williams
jack-williams / Text
Last active July 8, 2023 11:57
Excel text functions
_search = LAMBDA(txt, searchtext, [case_sensitive],
// Test the inputs for errors so that we can distinguish
// the error that comes from FIND/SEARCH as meaning "not-found".
IFS(
ISERROR(txt),
txt,
ISERROR(searchtext),
searchtext,
ISERROR(case_sensitive),
case_sensitive,
@jack-williams
jack-williams / datelib
Last active January 19, 2024 05:13
Excel Date Library
/**
* Returns the day of the week for the provided date,
* where Monday is the first day.
*/
dayOfWeek = LAMBDA(datetime, WEEKDAY(datetime, 2));
/**
* Returns the name for the day of the week for the provided date.
*/
dayOfWeekName = LAMBDA(datetime, TEXT(datetime, "dddd"));
interface Lit<K> {
kind: 'lit';
value: K;
}
interface BinOp<T> {
kind: 'binop';
l: T;
r: T;
}
@jack-williams
jack-williams / type-catcher.ts
Created April 1, 2018 22:18
Catch TypeScript types at run-time using Proxies.
interface ObjectType {
kind: "object"
props: {[k: string]: Type[]};
}
interface FunctionType {
kind: "function";
calls: CallType[];
}