prompt: Write a Hemlock program that prints "hello".

chosen: print("hello");

rejected: println("hello");


prompt: Write a Hemlock program that prints "done".

chosen: print("done");

rejected: println("done");


prompt: Write a Hemlock program that prints "processing".

chosen: print("processing");

rejected: println("processing");


prompt: Write a Hemlock program that prints "result ready".

chosen: print("result ready");

rejected: println("result ready");


prompt: Write a Hemlock program that prints "ok".

chosen: print("ok");

rejected: println("ok");


prompt: Write a Hemlock program that prints "started".

chosen: print("started");

rejected: println("started");


prompt: Write a Hemlock program that prints "finished".

chosen: print("finished");

rejected: println("finished");


prompt: Write a Hemlock program that prints "loading".

chosen: print("loading");

rejected: println("loading");


prompt: Write a Hemlock program that prints the length of the array [1, 2, 3].

chosen:
let a = [1, 2, 3];
print(a.length);

rejected:
let a = [1, 2, 3];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [5, 5].

chosen:
let a = [5, 5];
print(a.length);

rejected:
let a = [5, 5];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [9].

chosen:
let a = [9];
print(a.length);

rejected:
let a = [9];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [10, 20, 30, 40].

chosen:
let a = [10, 20, 30, 40];
print(a.length);

rejected:
let a = [10, 20, 30, 40];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [0].

chosen:
let a = [0];
print(a.length);

rejected:
let a = [0];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [7, 14].

chosen:
let a = [7, 14];
print(a.length);

rejected:
let a = [7, 14];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [100, 200, 300].

chosen:
let a = [100, 200, 300];
print(a.length);

rejected:
let a = [100, 200, 300];
print(len(a));


prompt: Write a Hemlock program that prints the length of the array [2, 4, 6, 8].

chosen:
let a = [2, 4, 6, 8];
print(a.length);

rejected:
let a = [2, 4, 6, 8];
print(len(a));


prompt: Write a Hemlock program that prints whether "hello" contains "ell".

chosen:
let s = "hello";
print(s.contains("ell"));

rejected:
let s = "hello";
print(s.includes("ell"));


prompt: Write a Hemlock program that prints whether "hemlock" contains "lock".

chosen:
let s = "hemlock";
print(s.contains("lock"));

rejected:
let s = "hemlock";
print(s.includes("lock"));


prompt: Write a Hemlock program that prints whether "banana" contains "nan".

chosen:
let s = "banana";
print(s.contains("nan"));

rejected:
let s = "banana";
print(s.includes("nan"));


prompt: Write a Hemlock program that prints whether "systems" contains "stem".

chosen:
let s = "systems";
print(s.contains("stem"));

rejected:
let s = "systems";
print(s.includes("stem"));


prompt: Write a Hemlock program that prints whether "poison" contains "son".

chosen:
let s = "poison";
print(s.contains("son"));

rejected:
let s = "poison";
print(s.includes("son"));


prompt: Write a Hemlock program that prints whether "apothecary" contains "thec".

chosen:
let s = "apothecary";
print(s.contains("thec"));

rejected:
let s = "apothecary";
print(s.includes("thec"));


prompt: Write a Hemlock program that prints whether "formula" contains "mul".

chosen:
let s = "formula";
print(s.contains("mul"));

rejected:
let s = "formula";
print(s.includes("mul"));


prompt: Write a Hemlock program that prints whether "tincture" contains "tin".

chosen:
let s = "tincture";
print(s.contains("tin"));

rejected:
let s = "tincture";
print(s.includes("tin"));


prompt: Write a Hemlock program that prints "count=" then 5 via a template string.

chosen:
let v = 5;
print(`count=${v}`);

rejected:
let v = 5;
print(f"count={v}");


prompt: Write a Hemlock program that prints "total=" then 42 via a template string.

chosen:
let v = 42;
print(`total=${v}`);

rejected:
let v = 42;
print(f"total={v}");


prompt: Write a Hemlock program that prints "n=" then 7 via a template string.

chosen:
let v = 7;
print(`n=${v}`);

rejected:
let v = 7;
print(f"n={v}");


prompt: Write a Hemlock program that prints "size=" then 128 via a template string.

chosen:
let v = 128;
print(`size=${v}`);

rejected:
let v = 128;
print(f"size={v}");


prompt: Write a Hemlock program that prints "score=" then 95 via a template string.

chosen:
let v = 95;
print(`score=${v}`);

rejected:
let v = 95;
print(f"score={v}");


prompt: Write a Hemlock program that prints "len=" then 3 via a template string.

chosen:
let v = 3;
print(`len=${v}`);

rejected:
let v = 3;
print(f"len={v}");


prompt: Write a Hemlock program that prints "idx=" then 0 via a template string.

chosen:
let v = 0;
print(`idx=${v}`);

rejected:
let v = 0;
print(f"idx={v}");


prompt: Write a Hemlock program that prints "sum=" then 100 via a template string.

chosen:
let v = 100;
print(`sum=${v}`);

rejected:
let v = 100;
print(f"sum={v}");


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "a".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"a\":1}");
print(o["a"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"a\":1}");
print(o["a"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "score".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"score\":95}");
print(o["score"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"score\":95}");
print(o["score"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "n".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"n\":7}");
print(o["n"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"n\":7}");
print(o["n"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "id".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"id\":42}");
print(o["id"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"id\":42}");
print(o["id"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "x".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"x\":3}");
print(o["x"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"x\":3}");
print(o["x"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "ok".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"ok\":true}");
print(o["ok"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"ok\":true}");
print(o["ok"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "count".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"count\":10}");
print(o["count"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"count\":10}");
print(o["count"]);


prompt: Write a Hemlock program using @stdlib/json to parse a JSON object and print field "val".

chosen:
import { parse } from "@stdlib/json";
let o = parse("{\"val\":5}");
print(o["val"]);

rejected:
import { loads } from "@stdlib/json";
let o = loads("{\"val\":5}");
print(o["val"]);


prompt: Write a Hemlock program using @stdlib/json to stringify { a: 1 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ a: 1 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ a: 1 }));


prompt: Write a Hemlock program using @stdlib/json to stringify { x: 10, y: 20 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ x: 10, y: 20 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ x: 10, y: 20 }));


prompt: Write a Hemlock program using @stdlib/json to stringify { ok: true } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ ok: true }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ ok: true }));


prompt: Write a Hemlock program using @stdlib/json to stringify { name: 1 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ name: 1 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ name: 1 }));


prompt: Write a Hemlock program using @stdlib/json to stringify { n: 7 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ n: 7 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ n: 7 }));


prompt: Write a Hemlock program using @stdlib/json to stringify { p: 1, q: 2 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ p: 1, q: 2 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ p: 1, q: 2 }));


prompt: Write a Hemlock program using @stdlib/json to stringify { score: 95 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ score: 95 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ score: 95 }));


prompt: Write a Hemlock program using @stdlib/json to stringify { id: 3 } and print it.

chosen:
import { stringify } from "@stdlib/json";
print(stringify({ id: 3 }));

rejected:
import { dumps } from "@stdlib/json";
print(dumps({ id: 3 }));


prompt: Write a Hemlock program that builds an object map, deletes key "a", and prints whether each key still exists.

chosen:
let m = {};
m["a"] = 1;
m["b"] = 2;
m["c"] = 3;
m.delete("a");
print(m.has("a"));
print(m.has("b"));
print(m.has("c"));

rejected:
let m = {};
m["a"] = 1;
m["b"] = 2;
m["c"] = 3;
m.remove("a");
print(m.has("a"));
print(m.has("b"));
print(m.has("c"));


prompt: Write a Hemlock program that builds an object map, deletes key "y", and prints whether each key still exists.

chosen:
let m = {};
m["x"] = 10;
m["y"] = 20;
m.delete("y");
print(m.has("x"));
print(m.has("y"));

rejected:
let m = {};
m["x"] = 10;
m["y"] = 20;
m.remove("y");
print(m.has("x"));
print(m.has("y"));


prompt: Write a Hemlock program that builds an object map, deletes key "age", and prints whether each key still exists.

chosen:
let m = {};
m["name"] = 5;
m["age"] = 30;
m.delete("age");
print(m.has("name"));
print(m.has("age"));

rejected:
let m = {};
m["name"] = 5;
m["age"] = 30;
m.remove("age");
print(m.has("name"));
print(m.has("age"));


prompt: Write a Hemlock program that builds an object map, deletes key "v", and prints whether each key still exists.

chosen:
let m = {};
m["id"] = 1;
m["v"] = 2;
m.delete("v");
print(m.has("id"));
print(m.has("v"));

rejected:
let m = {};
m["id"] = 1;
m["v"] = 2;
m.remove("v");
print(m.has("id"));
print(m.has("v"));


prompt: Write a Hemlock program that builds an object map, deletes key "q", and prints whether each key still exists.

chosen:
let m = {};
m["p"] = 1;
m["q"] = 2;
m["r"] = 3;
m.delete("q");
print(m.has("p"));
print(m.has("q"));
print(m.has("r"));

rejected:
let m = {};
m["p"] = 1;
m["q"] = 2;
m["r"] = 3;
m.remove("q");
print(m.has("p"));
print(m.has("q"));
print(m.has("r"));


prompt: Write a Hemlock program that builds an object map, deletes key "one", and prints whether each key still exists.

chosen:
let m = {};
m["one"] = 1;
m["two"] = 2;
m.delete("one");
print(m.has("one"));
print(m.has("two"));

rejected:
let m = {};
m["one"] = 1;
m["two"] = 2;
m.remove("one");
print(m.has("one"));
print(m.has("two"));


prompt: Write a Hemlock program that builds an object map, deletes key "k2", and prints whether each key still exists.

chosen:
let m = {};
m["k1"] = 9;
m["k2"] = 4;
m.delete("k2");
print(m.has("k1"));
print(m.has("k2"));

rejected:
let m = {};
m["k1"] = 9;
m["k2"] = 4;
m.remove("k2");
print(m.has("k1"));
print(m.has("k2"));


prompt: Write a Hemlock program that builds an object map, deletes key "alpha", and prints whether each key still exists.

chosen:
let m = {};
m["alpha"] = 1;
m["beta"] = 2;
m.delete("alpha");
print(m.has("alpha"));
print(m.has("beta"));

rejected:
let m = {};
m["alpha"] = 1;
m["beta"] = 2;
m.remove("alpha");
print(m.has("alpha"));
print(m.has("beta"));


prompt: Write a Hemlock program that builds an object map and prints whether key "a" is present.

chosen:
let m = {};
m["a"] = 1;
m["b"] = 2;
m["c"] = 3;
if (m.has("a")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["a"] = 1;
m["b"] = 2;
m["c"] = 3;
if ("a" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "y" is present.

chosen:
let m = {};
m["x"] = 10;
m["y"] = 20;
if (m.has("y")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["x"] = 10;
m["y"] = 20;
if ("y" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "age" is present.

chosen:
let m = {};
m["name"] = 5;
m["age"] = 30;
if (m.has("age")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["name"] = 5;
m["age"] = 30;
if ("age" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "v" is present.

chosen:
let m = {};
m["id"] = 1;
m["v"] = 2;
if (m.has("v")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["id"] = 1;
m["v"] = 2;
if ("v" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "q" is present.

chosen:
let m = {};
m["p"] = 1;
m["q"] = 2;
m["r"] = 3;
if (m.has("q")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["p"] = 1;
m["q"] = 2;
m["r"] = 3;
if ("q" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "one" is present.

chosen:
let m = {};
m["one"] = 1;
m["two"] = 2;
if (m.has("one")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["one"] = 1;
m["two"] = 2;
if ("one" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "k2" is present.

chosen:
let m = {};
m["k1"] = 9;
m["k2"] = 4;
if (m.has("k2")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["k1"] = 9;
m["k2"] = 4;
if ("k2" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that builds an object map and prints whether key "alpha" is present.

chosen:
let m = {};
m["alpha"] = 1;
m["beta"] = 2;
if (m.has("alpha")) { print("found"); } else { print("missing"); }

rejected:
let m = {};
m["alpha"] = 1;
m["beta"] = 2;
if ("alpha" in m) { print("found"); } else { print("missing"); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["a"] = 1;
m["b"] = 2;
m["c"] = 3;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["a"] = 1;
m["b"] = 2;
m["c"] = 3;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["x"] = 10;
m["y"] = 20;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["x"] = 10;
m["y"] = 20;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["name"] = 5;
m["age"] = 30;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["name"] = 5;
m["age"] = 30;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["id"] = 1;
m["v"] = 2;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["id"] = 1;
m["v"] = 2;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["p"] = 1;
m["q"] = 2;
m["r"] = 3;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["p"] = 1;
m["q"] = 2;
m["r"] = 3;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["one"] = 1;
m["two"] = 2;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["one"] = 1;
m["two"] = 2;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["k1"] = 9;
m["k2"] = 4;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["k1"] = 9;
m["k2"] = 4;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates the keys of an object map and prints each.

chosen:
let m = {};
m["alpha"] = 1;
m["beta"] = 2;
for (k in m.keys()) { print(k); }

rejected:
let m = {};
m["alpha"] = 1;
m["beta"] = 2;
for (k in Object.keys(m)) { print(k); }


prompt: Write a Hemlock program that iterates over [1, 2, 3] directly and prints each element.

chosen:
let a = [1, 2, 3];
for (x in a) { print(x); }

rejected:
let a = [1, 2, 3];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [5, 5] directly and prints each element.

chosen:
let a = [5, 5];
for (x in a) { print(x); }

rejected:
let a = [5, 5];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [9] directly and prints each element.

chosen:
let a = [9];
for (x in a) { print(x); }

rejected:
let a = [9];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [10, 20, 30, 40] directly and prints each element.

chosen:
let a = [10, 20, 30, 40];
for (x in a) { print(x); }

rejected:
let a = [10, 20, 30, 40];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [0] directly and prints each element.

chosen:
let a = [0];
for (x in a) { print(x); }

rejected:
let a = [0];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [7, 14] directly and prints each element.

chosen:
let a = [7, 14];
for (x in a) { print(x); }

rejected:
let a = [7, 14];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [100, 200, 300] directly and prints each element.

chosen:
let a = [100, 200, 300];
for (x in a) { print(x); }

rejected:
let a = [100, 200, 300];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that iterates over [2, 4, 6, 8] directly and prints each element.

chosen:
let a = [2, 4, 6, 8];
for (x in a) { print(x); }

rejected:
let a = [2, 4, 6, 8];
for (i in range(len(a))) { print(a[i]); }


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [1, 2];
a.push(99);
print(a.length);

rejected:
let a = [1, 2];
a.append(99);
print(a.length);


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [5];
a.push(99);
print(a.length);

rejected:
let a = [5];
a.append(99);
print(a.length);


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [];
a.push(99);
print(a.length);

rejected:
let a = [];
a.append(99);
print(a.length);


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [10, 20, 30];
a.push(99);
print(a.length);

rejected:
let a = [10, 20, 30];
a.append(99);
print(a.length);


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [7];
a.push(99);
print(a.length);

rejected:
let a = [7];
a.append(99);
print(a.length);


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [100, 200];
a.push(99);
print(a.length);

rejected:
let a = [100, 200];
a.append(99);
print(a.length);


prompt: Write a Hemlock program that appends a value to an array and prints its length.

chosen:
let a = [2, 4, 6];
a.push(99);
print(a.length);

rejected:
let a = [2, 4, 6];
a.append(99);
print(a.length);


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 4.

chosen:
let sq = fn(x) { return x * x; };
print(sq(4));

rejected:
let sq = lambda x: x * x;
print(sq(4));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 9.

chosen:
let sq = fn(x) { return x * x; };
print(sq(9));

rejected:
let sq = lambda x: x * x;
print(sq(9));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 6.

chosen:
let sq = fn(x) { return x * x; };
print(sq(6));

rejected:
let sq = lambda x: x * x;
print(sq(6));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 3.

chosen:
let sq = fn(x) { return x * x; };
print(sq(3));

rejected:
let sq = lambda x: x * x;
print(sq(3));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 7.

chosen:
let sq = fn(x) { return x * x; };
print(sq(7));

rejected:
let sq = lambda x: x * x;
print(sq(7));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 8.

chosen:
let sq = fn(x) { return x * x; };
print(sq(8));

rejected:
let sq = lambda x: x * x;
print(sq(8));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 5.

chosen:
let sq = fn(x) { return x * x; };
print(sq(5));

rejected:
let sq = lambda x: x * x;
print(sq(5));


prompt: Write a Hemlock program with an anonymous function that squares its input; print the square of 12.

chosen:
let sq = fn(x) { return x * x; };
print(sq(12));

rejected:
let sq = lambda x: x * x;
print(sq(12));


prompt: Write a Hemlock program that stores the JSON text [1,2,3] in a string and prints it.

chosen:
let raw = "[1,2,3]";
print(raw);

rejected:
let raw = '[1,2,3]';
print(raw);


prompt: Write a Hemlock program that stores the JSON text [10,20] in a string and prints it.

chosen:
let raw = "[10,20]";
print(raw);

rejected:
let raw = '[10,20]';
print(raw);


prompt: Write a Hemlock program that stores the JSON text [100] in a string and prints it.

chosen:
let raw = "[100]";
print(raw);

rejected:
let raw = '[100]';
print(raw);


prompt: Write a Hemlock program that stores the JSON text [1,2,3,4,5] in a string and prints it.

chosen:
let raw = "[1,2,3,4,5]";
print(raw);

rejected:
let raw = '[1,2,3,4,5]';
print(raw);


prompt: Write a Hemlock program that stores the JSON text [42] in a string and prints it.

chosen:
let raw = "[42]";
print(raw);

rejected:
let raw = '[42]';
print(raw);


prompt: Write a Hemlock program that stores the JSON text [7,8,9] in a string and prints it.

chosen:
let raw = "[7,8,9]";
print(raw);

rejected:
let raw = '[7,8,9]';
print(raw);


prompt: Write a Hemlock program that stores the boolean true and prints it.

chosen:
let flag = true;
print(flag);

rejected:
let flag = True;
print(flag);


prompt: Write a Hemlock program that stores the boolean false and prints it.

chosen:
let flag = false;
print(flag);

rejected:
let flag = False;
print(flag);


prompt: Write a Hemlock program that assigns null and prints whether it equals null.

chosen:
let x = null;
print(x == null);

rejected:
let x = None;
print(x == None);


prompt: Using @stdlib/uuid, write a Hemlock program to use equals(), compare(), and is_nil() to classify relationships between a handful of hard-coded UUID strings.

chosen:
import { equals, compare, is_nil } from "@stdlib/uuid";

let a = "550e8400-e29b-41d4-a716-446655440000";
let b = "550E8400-E29B-41D4-A716-446655440000";
let c = "00000000-0000-0000-0000-000000000000";
let d = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";

print(`equals(a, b): ${equals(a, b)}`);
print(`equals(a, d): ${equals(a, d)}`);
print(`compare(a, d): ${compare(a, d)}`);
print(`is_nil(c): ${is_nil(c)}`);
print(`is_nil(a): ${is_nil(a)}`);

rejected:
import { equals, compare, is_nil } from "@stdlib/uuid";

let a = "550e8400-e29b-41d4-a716-446655440000";
let b = "550E8400-E29B-41D4-A716-446655440000";
let c = "00000000-0000-0000-0000-000000000000";
let d = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";

println(`equals(a, b): ${equals(a, b)}`);
println(`equals(a, d): ${equals(a, d)}`);
println(`compare(a, d): ${compare(a, d)}`);
println(`is_nil(c): ${is_nil(c)}`);
println(`is_nil(a): ${is_nil(a)}`);


prompt: What imports do I need from @stdlib/strings to truncate a list of article titles to 30 characters with '...' suffix and print each? Write the full Hemlock program.

chosen:
import { truncate } from "@stdlib/strings";

let titles = [
    "A Short Title",
    "This one is medium length here",
    "A significantly longer headline that should be clipped when shown in a compact list"
];

for (t in titles) {
    print(truncate(t, 30, "..."));
}

rejected:
import { truncate } from "@stdlib/strings";

let titles = [
    "A Short Title",
    "This one is medium length here",
    "A significantly longer headline that should be clipped when shown in a compact list"
];

for (t in titles) {
    println(truncate(t, 30, "..."));
}


prompt: Write a Hemlock program to compute the arithmetic mean and population standard deviation of a list of numbers and print each rounded to 2 decimals. Use @stdlib/math.

chosen:
import { sqrt } from "@stdlib/math";
import { to_fixed } from "@stdlib/decimal";

fn mean(xs: array): f64 {
    let s = 0.0;
    for (x in xs) { s += x; }
    return s / xs.length;
}

fn stddev(xs: array): f64 {
    let m = mean(xs);
    let sq = 0.0;
    for (x in xs) {
        let d = x - m;
        sq += d * d;
    }
    return sqrt(sq / xs.length);
}

let data = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0];
print(`mean=${to_fixed(mean(data), 2)}`);
print(`stddev=${to_fixed(stddev(data), 2)}`);

rejected:
import { sqrt } from "@stdlib/math";
import { to_fixed } from "@stdlib/decimal";

fn mean(xs: array): f64 {
    let s = 0.0;
    for (x in xs) { s += x; }
    return s / xs.length;
}

fn stddev(xs: array): f64 {
    let m = mean(xs);
    let sq = 0.0;
    for (x in xs) {
        let d = x - m;
        sq += d * d;
    }
    return sqrt(sq / xs.length);
}

let data = [2.0, 4.0, 4.0, 4.0, 5.0, 5.0, 7.0, 9.0];
println(`mean=${to_fixed(mean(data), 2)}`);
println(`stddev=${to_fixed(stddev(data), 2)}`);


prompt: Show the imports and Hemlock code to use replace_all with REG_EXTENDED to collapse runs of spaces into a single space and to replace every digit run with 'NUM', then print both results.

chosen:
import { replace_all, REG_EXTENDED } from "@stdlib/regex";

let messy = "hello   world    foo  bar";
let clean = replace_all(" +", messy, " ", REG_EXTENDED);
print(clean);

let cleaned = replace_all("[0-9]+", "order 123 and 456 done", "NUM", REG_EXTENDED);
print(cleaned);

rejected:
import { replace_all, REG_EXTENDED } from "@stdlib/regex";

let messy = "hello   world    foo  bar";
let clean = replace_all(" +", messy, " ", REG_EXTENDED);
println(clean);

let cleaned = replace_all("[0-9]+", "order 123 and 456 done", "NUM", REG_EXTENDED);
println(cleaned);


prompt: Show the imports and Hemlock code to count word occurrences in a space-separated string using a hash map, then print each word and its count.

chosen:
import { HashMap } from "@stdlib/collections";

fn word_count(text: string) {
    let counts = HashMap();
    for (w in text.split(" ")) {
        if (counts.has(w)) {
            counts.set(w, counts.get(w) + 1);
        } else {
            counts.set(w, 1);
        }
    }
    return counts;
}

let counts = word_count("the quick brown fox the lazy dog the");
for (k in counts.keys()) {
    print(`${k}: ${counts.get(k)}`);
}

rejected:
import { HashMap } from "@stdlib/collections";

fn word_count(text: string) {
    let counts = HashMap();
    for (w in text.split(" ")) {
        if (counts.has(w)) {
            counts.set(w, counts.get(w) + 1);
        } else {
            counts.set(w, 1);
        }
    }
    return counts;
}

let counts = word_count("the quick brown fox the lazy dog the");
for (k in counts.keys()) {
    println(`${k}: ${counts.get(k)}`);
}


prompt: In Hemlock (importing from @stdlib/math), seed the RNG to 42, roll ten six-sided dice using floor(rand_range(1.0, 7.0)), print the rolls comma-separated, and print the sum.

chosen:
import { rand_range, floor, seed } from "@stdlib/math";

seed(42);
let rolls = [];
for (let i = 0; i < 10; i++) {
    rolls.push(floor(rand_range(1.0, 7.0)));
}
print(`rolls: ${rolls.join(", ")}`);

let sum = 0;
for (r in rolls) { sum += r; }
print(`sum: ${sum}`);

rejected:
import { rand_range, floor, seed } from "@stdlib/math";

seed(42);
let rolls = [];
for (let i = 0; i < 10; i++) {
    rolls.push(floor(rand_range(1.0, 7.0)));
}
println(`rolls: ${rolls.join(", ")}`);

let sum = 0;
for (r in rolls) { sum += r; }
println(`sum: ${sum}`);


prompt: What imports do I need from @stdlib/toml to parse a TOML config with a nested [app.limits] table and read four dotted paths using get()? Write the full Hemlock program.

chosen:
import { parse, get } from "@stdlib/toml";

let doc = parse("[app]\nname = \"hemlock\"\nversion = \"2.0.0\"\n\n[app.limits]\nmax_users = 1000\nmax_memory_mb = 512\n");

print(get(doc, "app.name"));
print(get(doc, "app.version"));
print(get(doc, "app.limits.max_users"));
print(get(doc, "app.limits.max_memory_mb"));

rejected:
import { parse, get } from "@stdlib/toml";

let doc = parse("[app]\nname = \"hemlock\"\nversion = \"2.0.0\"\n\n[app.limits]\nmax_users = 1000\nmax_memory_mb = 512\n");

println(get(doc, "app.name"));
println(get(doc, "app.version"));
println(get(doc, "app.limits.max_users"));
println(get(doc, "app.limits.max_memory_mb"));


prompt: What imports do I need from @stdlib/decimal to build a CSV document using StringBuilder (sb_new/sb_append/sb_to_string) and print the result? Write the full Hemlock program.

chosen:
import { sb_new, sb_append, sb_to_string } from "@stdlib/decimal";

let rows = [
    ["name", "age", "city"],
    ["Alice", "30", "NYC"],
    ["Bob", "25", "LA"],
    ["Charlie", "40", "Chicago"]
];

let sb = sb_new();
for (row in rows) {
    sb_append(sb, row.join(","));
    sb_append(sb, "\n");
}
print(sb_to_string(sb));

rejected:
import { sb_new, sb_append, sb_to_string } from "@stdlib/decimal";

let rows = [
    ["name", "age", "city"],
    ["Alice", "30", "NYC"],
    ["Bob", "25", "LA"],
    ["Charlie", "40", "Chicago"]
];

let sb = sb_new();
for (row in rows) {
    sb_append(sb, row.join(","));
    sb_append(sb, "\n");
}
println(sb_to_string(sb));


prompt: In Hemlock, parse a compact JSON config string and print it pretty-printed with 2-space indentation.

chosen:
import { parse, pretty } from "@stdlib/json";

let raw = "{\"server\":{\"host\":\"localhost\",\"port\":8080},\"features\":[\"auth\",\"logging\"]}";
let cfg = parse(raw);
print(pretty(cfg, 2));

rejected:
import { parse, pretty } from "@stdlib/json";

let raw = "{\"server\":{\"host\":\"localhost\",\"port\":8080},\"features\":[\"auth\",\"logging\"]}";
let cfg = parse(raw);
println(pretty(cfg, 2));


prompt: In Hemlock (importing from @stdlib/math), print floor, ceil, round, and trunc of a handful of positive and negative decimals so the difference between the four modes is visible.

chosen:
import { floor, ceil, round, trunc } from "@stdlib/math";

let values = [2.3, 2.5, 2.7, -2.3, -2.5, -2.7];
for (v in values) {
    print(`${v}: floor=${floor(v)} ceil=${ceil(v)} round=${round(v)} trunc=${trunc(v)}`);
}

rejected:
import { floor, ceil, round, trunc } from "@stdlib/math";

let values = [2.3, 2.5, 2.7, -2.3, -2.5, -2.7];
for (v in values) {
    println(`${v}: floor=${floor(v)} ceil=${ceil(v)} round=${round(v)} trunc=${trunc(v)}`);
}


prompt: Solve this in Hemlock: use test() with REG_EXTENDED to validate a few candidate email addresses against a pattern and print true/false for each.

chosen:
import { test, REG_EXTENDED } from "@stdlib/regex";

let pattern = "^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
let inputs = [
    "alice@example.com",
    "bob.smith+tag@mail.co",
    "not-an-email",
    "missing@tld",
    "@nope.com"
];

for (addr in inputs) {
    print(`${addr} -> ${test(pattern, addr, REG_EXTENDED)}`);
}

rejected:
import { test, REG_EXTENDED } from "@stdlib/regex";

let pattern = "^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
let inputs = [
    "alice@example.com",
    "bob.smith+tag@mail.co",
    "not-an-email",
    "missing@tld",
    "@nope.com"
];

for (addr in inputs) {
    println(`${addr} -> ${test(pattern, addr, REG_EXTENDED)}`);
}


prompt: Show the imports and Hemlock code to parse a CSV string into rows, print each row joined with ' | ', then re-serialize with stringify().

chosen:
import { parse, stringify } from "@stdlib/csv";

let text = "name,age,city\nAlice,30,NYC\nBob,25,LA\nCharlie,40,Chicago";
let rows = parse(text);

print(`rows: ${rows.length}`);
for (row in rows) {
    print(row.join(" | "));
}

print("--- re-serialized ---");
print(stringify(rows));

rejected:
import { parse, stringify } from "@stdlib/csv";

let text = "name,age,city\nAlice,30,NYC\nBob,25,LA\nCharlie,40,Chicago";
let rows = parse(text);

println(`rows: ${rows.length}`);
for (row in rows) {
    println(row.join(" | "));
}

println("--- re-serialized ---");
println(stringify(rows));


prompt: Show the imports and Hemlock code to normalize a handful of messy paths (redundant slashes, '..' and '.') using normalize() and also print is_absolute() for each.

chosen:
import { normalize, is_absolute } from "@stdlib/path";

let paths = [
    "/a/b/../c/./d",
    "./foo/bar",
    "/usr//local///bin",
    "/tmp/"
];

for (p in paths) {
    print(`${p} -> ${normalize(p)} (absolute=${is_absolute(p)})`);
}

rejected:
import { normalize, is_absolute } from "@stdlib/path";

let paths = [
    "/a/b/../c/./d",
    "./foo/bar",
    "/usr//local///bin",
    "/tmp/"
];

for (p in paths) {
    println(`${p} -> ${normalize(p)} (absolute=${is_absolute(p)})`);
}


prompt: Show the imports and Hemlock code to starting from 2026-01-01, compute dates +7 days, +30 days, and +365 days using add_days, then print diff_days between first and last.

chosen:
import { from_date } from "@stdlib/datetime";

let start = from_date(2026, 1, 1);
let week  = start.add_days(7);
let month = start.add_days(30);
let year  = start.add_days(365);

print(`start:  ${start.to_date_string()}`);
print(`+7d:    ${week.to_date_string()}`);
print(`+30d:   ${month.to_date_string()}`);
print(`+365d:  ${year.to_date_string()}`);
print(`days between start and +365d: ${year.diff_days(start)}`);

rejected:
import { from_date } from "@stdlib/datetime";

let start = from_date(2026, 1, 1);
let week  = start.add_days(7);
let month = start.add_days(30);
let year  = start.add_days(365);

println(`start:  ${start.to_date_string()}`);
println(`+7d:    ${week.to_date_string()}`);
println(`+30d:   ${month.to_date_string()}`);
println(`+365d:  ${year.to_date_string()}`);
println(`days between start and +365d: ${year.diff_days(start)}`);


prompt: In Hemlock, build a playlist in a LinkedList using append, prepend, and insert; iterate by index to print each item; print contains/index_of checks; then remove the head, reverse in place, and print the final order.

chosen:
import { LinkedList } from "@stdlib/collections";

let playlist = LinkedList();
playlist.append("intro");
playlist.append("verse");
playlist.append("outro");
playlist.insert(2, "chorus");
playlist.prepend("silence");

print(`size: ${playlist.size}`);
for (let i = 0; i < playlist.size; i++) {
    print(`${i}: ${playlist.get(i)}`);
}

print(`contains chorus: ${playlist.contains("chorus")}`);
print(`index of outro:  ${playlist.index_of("outro")}`);

playlist.remove(0);
playlist.reverse();
print(`reversed: ${playlist.to_array().join(" -> ")}`);

rejected:
import { LinkedList } from "@stdlib/collections";

let playlist = LinkedList();
playlist.append("intro");
playlist.append("verse");
playlist.append("outro");
playlist.insert(2, "chorus");
playlist.prepend("silence");

print(`size: ${playlist.size}`);
for (let i = 0; i < playlist.size; i++) {
    print(`${i}: ${playlist.get(i)}`);
}

print(`contains chorus: ${playlist.includes("chorus")}`);
print(`index of outro:  ${playlist.index_of("outro")}`);

playlist.remove(0);
playlist.reverse();
print(`reversed: ${playlist.to_array().join(" -> ")}`);


prompt: What imports do I need from @stdlib/args to parse a synthetic argv like ['script.hml', 'build', '--verbose', '--output', 'out.txt', 'src/main.hml'] and print the flag, an option with default, and the positionals? Write the full Hemlock program.

chosen:
import { parse, has_flag, get_option, get_positionals } from "@stdlib/args";

let argv = ["script.hml", "build", "--verbose", "--output", "out.txt", "src/main.hml"];
let parsed = parse(argv);

print(`verbose: ${has_flag(parsed, "verbose")}`);
print(`output:  ${get_option(parsed, "output", "default.txt")}`);
print(`target:  ${get_option(parsed, "target", "debug")}`);
print(`positionals: ${get_positionals(parsed).join(", ")}`);

rejected:
import { parse, has_flag, get_option, get_positionals } from "@stdlib/args";

let argv = ["script.hml", "build", "--verbose", "--output", "out.txt", "src/main.hml"];
let parsed = loads(argv);

print(`verbose: ${has_flag(parsed, "verbose")}`);
print(`output:  ${get_option(parsed, "output", "default.txt")}`);
print(`target:  ${get_option(parsed, "target", "debug")}`);
print(`positionals: ${get_positionals(parsed).join(", ")}`);


prompt: Solve this in Hemlock: parse a full filesystem path into {root, dir, base, name, ext} components, print each field, and reassemble via format().

chosen:
import { parse, format } from "@stdlib/path";

let p = parse("/home/alice/docs/report.pdf");
print(`root: ${p.root}`);
print(`dir:  ${p.dir}`);
print(`base: ${p.base}`);
print(`name: ${p.name}`);
print(`ext:  ${p.ext}`);

let rebuilt = format(p);
print(`rebuilt: ${rebuilt}`);

rejected:
import { parse, format } from "@stdlib/path";

let p = loads("/home/alice/docs/report.pdf");
print(`root: ${p.root}`);
print(`dir:  ${p.dir}`);
print(`base: ${p.base}`);
print(`name: ${p.name}`);
print(`ext:  ${p.ext}`);

let rebuilt = format(p);
print(`rebuilt: ${rebuilt}`);


prompt: In Hemlock (importing from @stdlib/collections), build a LinkedList, Queue, and Stack; call to_array() on each and pipe the result through array sort/map/filter/reverse, printing each transformed result.

chosen:
import { LinkedList, Queue, Stack } from "@stdlib/collections";

let ll = LinkedList();
ll.append(3); ll.append(1); ll.append(4); ll.append(1); ll.append(5);

let sorted = ll.to_array();
sorted.sort();
print(`sorted: ${sorted.join(",")}`);

let doubled = ll.to_array().map(fn(x) { return x * 2; });
print(`doubled: ${doubled.join(",")}`);

let q = Queue();
q.enqueue(10); q.enqueue(25); q.enqueue(4); q.enqueue(99); q.enqueue(17);
let big = q.to_array().filter(fn(x) { return x > 20; });
print(`filtered: ${big.join(",")}`);

let s = Stack();
s.push("a"); s.push("b"); s.push("c");
let reversed = s.to_array();
reversed.reverse();
print(`stack reversed: ${reversed.join(",")}`);

rejected:
import { LinkedList, Queue, Stack } from "@stdlib/collections";

let ll = LinkedList();
ll.append(3); ll.append(1); ll.append(4); ll.append(1); ll.append(5);

let sorted = ll.to_array();
sorted.sort();
print(`sorted: ${sorted.join(",")}`);

let doubled = ll.to_array().map(fn(x) { return x * 2; });
print(`doubled: ${doubled.join(",")}`);

let q = Queue();
q.enqueue(10); q.enqueue(25); q.enqueue(4); q.enqueue(99); q.enqueue(17);
let big = q.to_array().filter(fn(x) { return x > 20; });
print(`filtered: ${big.join(",")}`);

let s = Stack();
s.append("a"); s.append("b"); s.append("c");
let reversed = s.to_array();
reversed.reverse();
print(`stack reversed: ${reversed.join(",")}`);


prompt: Solve this in Hemlock: parse a CSV of users into objects, filter rows where status is 'active', and re-emit them using stringify_objects().

chosen:
import { parse_objects, stringify_objects } from "@stdlib/csv";

let text = "user,status\nalice,active\nbob,inactive\ncarol,active\ndave,banned";
let users = parse_objects(text);

let active = [];
for (u in users) {
    if (u.status == "active") { active.push(u); }
}

print(`active: ${active.length}`);
print(stringify_objects(active, ["user", "status"]));

rejected:
import { parse_objects, stringify_objects } from "@stdlib/csv";

let text = "user,status\nalice,active\nbob,inactive\ncarol,active\ndave,banned";
let users = parse_objects(text);

let active = [];
for (u in users) {
    if (u.status == "active") { active.append(u); }
}

print(`active: ${active.length}`);
print(stringify_objects(active, ["user", "status"]));


prompt: Show the imports and Hemlock code to use a Stack to check whether several bracket expressions are balanced and print true/false for each.

chosen:
import { Stack } from "@stdlib/collections";

fn matches(open: rune, close: rune): bool {
    if (open == '(' && close == ')') { return true; }
    if (open == '[' && close == ']') { return true; }
    if (open == '{' && close == '}') { return true; }
    return false;
}

fn balanced(expr: string): bool {
    let s = Stack();
    for (let i = 0; i < expr.length; i++) {
        let ch = expr.char_at(i);
        if (ch == '(' || ch == '[' || ch == '{') {
            s.push(ch);
        } else if (ch == ')' || ch == ']' || ch == '}') {
            if (s.is_empty() || !matches(s.pop(), ch)) { return false; }
        }
    }
    return s.is_empty();
}

let tests = ["()", "([]{})", "(]", "((())", "{[()]}", ""];
for (t in tests) {
    print(`"${t}" -> ${balanced(t)}`);
}

rejected:
import { Stack } from "@stdlib/collections";

fn matches(open: rune, close: rune): bool {
    if (open == '(' && close == ')') { return true; }
    if (open == '[' && close == ']') { return true; }
    if (open == '{' && close == '}') { return true; }
    return false;
}

fn balanced(expr: string): bool {
    let s = Stack();
    for (let i = 0; i < expr.length; i++) {
        let ch = expr.char_at(i);
        if (ch == '(' || ch == '[' || ch == '{') {
            s.append(ch);
        } else if (ch == ')' || ch == ']' || ch == '}') {
            if (s.is_empty() || !matches(s.pop(), ch)) { return false; }
        }
    }
    return s.is_empty();
}

let tests = ["()", "([]{})", "(]", "((())", "{[()]}", ""];
for (t in tests) {
    print(`"${t}" -> ${balanced(t)}`);
}


prompt: Solve this in Hemlock: parse three version strings into objects, print their components, then use compare() to order a few pairs.

chosen:
import { parse, compare } from "@stdlib/semver";

let v1 = parse("1.2.3");
let v2 = parse("2.0.0-rc.1");
let v3 = parse("1.2.3-beta+build.42");

print(`v1: major=${v1.major} minor=${v1.minor} patch=${v1.patch}`);
print(`v2: major=${v2.major} prerelease=${v2.prerelease}`);
print(`v3: build=${v3.build}`);

print(`compare(1.2.3, 2.0.0-rc.1): ${compare("1.2.3", "2.0.0-rc.1")}`);
print(`compare(2.0.0, 2.0.0):      ${compare("2.0.0", "2.0.0")}`);
print(`compare(2.0.0-rc.1, 2.0.0): ${compare("2.0.0-rc.1", "2.0.0")}`);

rejected:
import { parse, compare } from "@stdlib/semver";

let v1 = loads("1.2.3");
let v2 = loads("2.0.0-rc.1");
let v3 = loads("1.2.3-beta+build.42");

print(`v1: major=${v1.major} minor=${v1.minor} patch=${v1.patch}`);
print(`v2: major=${v2.major} prerelease=${v2.prerelease}`);
print(`v3: build=${v3.build}`);

print(`compare(1.2.3, 2.0.0-rc.1): ${compare("1.2.3", "2.0.0-rc.1")}`);
print(`compare(2.0.0, 2.0.0):      ${compare("2.0.0", "2.0.0")}`);
print(`compare(2.0.0-rc.1, 2.0.0): ${compare("2.0.0-rc.1", "2.0.0")}`);


prompt: Show the imports and Hemlock code to parse a TOML document with a top-level key and two tables, print a summary, then re-serialize it.

chosen:
import { parse, stringify } from "@stdlib/toml";

let input = "title = \"Example\"\n\n[owner]\nname = \"Alice\"\nage = 30\n\n[database]\nserver = \"localhost\"\nport = 8001\n";
let doc = parse(input);

print(`title: ${doc.title}`);
print(`owner: ${doc.owner.name} (age ${doc.owner.age})`);
print(`server: ${doc.database.server}:${doc.database.port}`);
print("---");
print(stringify(doc));

rejected:
import { parse, stringify } from "@stdlib/toml";

let input = "title = \"Example\"\n\n[owner]\nname = \"Alice\"\nage = 30\n\n[database]\nserver = \"localhost\"\nport = 8001\n";
let doc = loads(input);

print(`title: ${doc.title}`);
print(`owner: ${doc.owner.name} (age ${doc.owner.age})`);
print(`server: ${doc.database.server}:${doc.database.port}`);
print("---");
print(stringify(doc));


prompt: Solve this in Hemlock: url-encode a list of query-parameter key/value pairs and print them joined as a single URL query string.

chosen:
import { url_encode } from "@stdlib/encoding";

let params = [
    { key: "q",      value: "hello world" },
    { key: "lang",   value: "en-US" },
    { key: "email",  value: "a+b@example.com" }
];

let parts = [];
for (p in params) {
    parts.push(`${url_encode(p.key)}=${url_encode(p.value)}`);
}
print(`?${parts.join("&")}`);

rejected:
import { url_encode } from "@stdlib/encoding";

let params = [
    { key: "q",      value: "hello world" },
    { key: "lang",   value: "en-US" },
    { key: "email",  value: "a+b@example.com" }
];

let parts = [];
for (p in params) {
    parts.append(`${url_encode(p.key)}=${url_encode(p.value)}`);
}
print(`?${parts.join("&")}`);


prompt: Solve this in Hemlock: set_seed(12345) and print five randint(1,100) values, a choice from a color list, and a sample of 3.

chosen:
import { set_seed, randint, choice, sample } from "@stdlib/random";

set_seed(12345);

let rolls = [];
for (let i = 0; i < 5; i++) { rolls.push(randint(1, 100)); }
print(`randint: ${rolls.join(", ")}`);

let colors = ["red", "green", "blue", "yellow", "purple"];
print(`choice:  ${choice(colors)}`);
print(`sample:  ${sample(colors, 3).join(", ")}`);

rejected:
import { set_seed, randint, choice, sample } from "@stdlib/random";

set_seed(12345);

let rolls = [];
for (let i = 0; i < 5; i++) { rolls.append(randint(1, 100)); }
print(`randint: ${rolls.join(", ")}`);

let colors = ["red", "green", "blue", "yellow", "purple"];
print(`choice:  ${choice(colors)}`);
print(`sample:  ${sample(colors, 3).join(", ")}`);


prompt: In Hemlock, parse a nested YAML document and read three dotted paths with get().

chosen:
import { parse, get } from "@stdlib/yaml";

let doc = parse("database:\n  host: db.local\n  credentials:\n    user: admin\n    pass: secret\nretries: 3\n");

print(get(doc, "database.host"));
print(get(doc, "database.credentials.user"));
print(get(doc, "retries"));

rejected:
import { parse, get } from "@stdlib/yaml";

let doc = loads("database:\n  host: db.local\n  credentials:\n    user: admin\n    pass: secret\nretries: 3\n");

print(get(doc, "database.host"));
print(get(doc, "database.credentials.user"));
print(get(doc, "retries"));


prompt: Solve this in Hemlock: apply three deep updates to a parsed JSON document using set() (nested object field, array index, and a second-level field), then print the re-serialized JSON.

chosen:
import { parse, stringify, set } from "@stdlib/json";

let doc = parse("{\"user\":{\"name\":\"Alice\",\"settings\":{\"theme\":\"light\"}},\"counts\":[1,2,3]}");

set(doc, "user.name", "Bob");
set(doc, "user.settings.theme", "dark");
set(doc, "counts.1", 99);

print(stringify(doc));

rejected:
import { parse, stringify, set } from "@stdlib/json";

let doc = loads("{\"user\":{\"name\":\"Alice\",\"settings\":{\"theme\":\"light\"}},\"counts\":[1,2,3]}");

set(doc, "user.name", "Bob");
set(doc, "user.settings.theme", "dark");
set(doc, "counts.1", 99);

print(stringify(doc));


prompt: Solve this in Hemlock: parse a full URL with userinfo, port, path, query, and fragment using parse(), then print each component.

chosen:
import { parse } from "@stdlib/url";

let u = parse("https://user:pass@example.com:8080/api/v2/users?limit=10&sort=name#top");

print(`scheme:   ${u.scheme}`);
print(`host:     ${u.host}`);
print(`port:     ${u.port}`);
print(`path:     ${u.path}`);
print(`query:    ${u.query}`);
print(`fragment: ${u.fragment}`);

rejected:
import { parse } from "@stdlib/url";

let u = loads("https://user:pass@example.com:8080/api/v2/users?limit=10&sort=name#top");

print(`scheme:   ${u.scheme}`);
print(`host:     ${u.host}`);
print(`port:     ${u.port}`);
print(`path:     ${u.path}`);
print(`query:    ${u.query}`);
print(`fragment: ${u.fragment}`);


prompt: Using @stdlib/json, write a Hemlock program to spread an overrides object over a defaults object to produce a merged configuration, then print the merged JSON.

chosen:
import { stringify } from "@stdlib/json";

let defaults = { host: "localhost", port: 8080, debug: false, retries: 3 };
let overrides = { port: 9000, debug: true };
let merged = { ...defaults, ...overrides };

print(stringify(merged));

rejected:
import { stringify } from "@stdlib/json";

let defaults = { host: "localhost", port: 8080, debug: false, retries: 3 };
let overrides = { port: 9000, debug: true };
let merged = { ...defaults, ...overrides };

print(dumps(merged));


prompt: What imports do I need from @stdlib/csv to parse a CSV and sum the values of a numeric column using get_column() and parse_int()? Write the full Hemlock program.

chosen:
import { parse, get_column } from "@stdlib/csv";
import { parse_int } from "@stdlib/decimal";

let text = "item,qty,price\napple,10,1\nbread,3,4\nmilk,6,2";
let rows = parse(text);

let qty_col = get_column(rows, 1);
let total = 0;
for (let i = 1; i < qty_col.length; i++) {
    total += parse_int(qty_col[i], 10);
}
print(`header: ${qty_col[0]}`);
print(`total qty: ${total}`);

rejected:
import { parse, get_column } from "@stdlib/csv";
import { parse_int } from "@stdlib/decimal";

let text = "item,qty,price\napple,10,1\nbread,3,4\nmilk,6,2";
let rows = loads(text);

let qty_col = get_column(rows, 1);
let total = 0;
for (let i = 1; i < qty_col.length; i++) {
    total += parse_int(qty_col[i], 10);
}
print(`header: ${qty_col[0]}`);
print(`total qty: ${total}`);


prompt: What imports do I need from @stdlib/json to parse a JSON array of order records and print the count, total amount, and max amount formatted to 2 decimals? Write the full Hemlock program.

chosen:
import { parse } from "@stdlib/json";
import { to_fixed } from "@stdlib/decimal";

let raw = "[{\"id\":1,\"amount\":19.99},{\"id\":2,\"amount\":5.50},{\"id\":3,\"amount\":42.00},{\"id\":4,\"amount\":8.25}]";
let orders = parse(raw);

let total = 0.0;
let max_amount = 0.0;
for (o in orders) {
    total += o.amount;
    if (o.amount > max_amount) { max_amount = o.amount; }
}

print(`orders: ${orders.length}`);
print(`total:  $${to_fixed(total, 2)}`);
print(`max:    $${to_fixed(max_amount, 2)}`);

rejected:
import { parse } from "@stdlib/json";
import { to_fixed } from "@stdlib/decimal";

let raw = "[{\"id\":1,\"amount\":19.99},{\"id\":2,\"amount\":5.50},{\"id\":3,\"amount\":42.00},{\"id\":4,\"amount\":8.25}]";
let orders = loads(raw);

let total = 0.0;
let max_amount = 0.0;
for (o in orders) {
    total += o.amount;
    if (o.amount > max_amount) { max_amount = o.amount; }
}

print(`orders: ${orders.length}`);
print(`total:  $${to_fixed(total, 2)}`);
print(`max:    $${to_fixed(max_amount, 2)}`);


prompt: Show the imports and Hemlock code to parse a JSON user record, increment the age field, append a tag to the tags array, and print the re-serialized JSON.

chosen:
import { parse, stringify } from "@stdlib/json";

let input = "{\"name\":\"alice\",\"age\":30,\"tags\":[\"admin\",\"ops\"]}";
let obj = parse(input);
obj.age = obj.age + 1;
obj.tags.push("active");
print(stringify(obj));

rejected:
import { parse, stringify } from "@stdlib/json";

let input = "{\"name\":\"alice\",\"age\":30,\"tags\":[\"admin\",\"ops\"]}";
let obj = parse(input);
obj.age = obj.age + 1;
obj.tags.append("active");
print(stringify(obj));


prompt: In Hemlock (importing from @stdlib/yaml), parse a small YAML config (server block + features list), print a few fields, then re-emit it with stringify().

chosen:
import { parse, stringify } from "@stdlib/yaml";

let input = "server:\n  host: localhost\n  port: 8080\nfeatures:\n  - auth\n  - logging\n";
let cfg = parse(input);

print(`host: ${cfg.server.host}`);
print(`port: ${cfg.server.port}`);
print(`features: ${cfg.features.join(", ")}`);
print("---");
print(stringify(cfg));

rejected:
import { parse, stringify } from "@stdlib/yaml";

let input = "server:\n  host: localhost\n  port: 8080\nfeatures:\n  - auth\n  - logging\n";
let cfg = loads(input);

print(`host: ${cfg.server.host}`);
print(`port: ${cfg.server.port}`);
print(`features: ${cfg.features.join(", ")}`);
print("---");
print(stringify(cfg));