benni-ben's picture
fix
c133250 verified
Raw History Blame Contribute Delete
17.5 kB
{
"_readme": "Closed vocabulary of library functions shared by every language. Generated code may call only these (plain calls) or SUBs it defines itself (via CALL). 'use_for' = the task the function handles; 'does' = how it behaves.",
"types": [
"Text",
"Number",
"Flag",
"Pile",
"Ledger",
"Vibe"
],
"languages": [
"C",
"Python",
"C++",
"Brainfuck",
"VBA",
"COBOL",
"Perl"
],
"rules": {
"reminder": "remind_computer(\"<Language>\"); right after the #include, as the first statement of every SUB (after the docstring) and of every PERFORM body. Language must be one of the supported names.",
"comments": {
"marker": "//",
"min_chars": 40,
"max_gap_chars": 300,
"checker_slack_chars": 330,
"text": "Every code block needs at least one comment of 40+ characters (counted after the //), and no stretch of more than ~300 characters of code may pass without one."
}
},
"functions": [
{
"name": "blurt",
"signature": "blurt($text)",
"category": "io",
"use_for": "print or output text",
"does": "Announces the text to the computer, which displays it once it has finished listening."
},
{
"name": "bellow",
"signature": "bellow($text)",
"category": "io",
"use_for": "print an error or emphasized message",
"does": "Announces the text at full volume; adds 1 point to the current scream chance per call."
},
{
"name": "pester_user",
"signature": "pester_user($prompt) -> Text",
"category": "io",
"use_for": "read user input",
"does": "Asks the user on the computer's behalf and holds the answer in short-term memory for about four seconds."
},
{
"name": "flip_text",
"signature": "flip_text($text) -> Text",
"category": "strings",
"use_for": "reverse a string",
"does": "Turns the string over end to end; costs 1 MB of memory per 100 characters."
},
{
"name": "smoosh_text",
"signature": "smoosh_text($a, $b) -> Text",
"category": "strings",
"use_for": "concatenate strings",
"does": "Bonds two strings with a mild adhesive; long strings may need to dry."
},
{
"name": "weigh_text",
"signature": "weigh_text($text) -> Number",
"category": "strings",
"use_for": "get a string's length",
"does": "Weighs the text on an internal scale and reports its length in characters."
},
{
"name": "shout_case",
"signature": "shout_case($text) -> Text",
"category": "strings",
"use_for": "convert to uppercase",
"does": "Raises the text's voice until every character stands up straight."
},
{
"name": "whisper_case",
"signature": "whisper_case($text) -> Text",
"category": "strings",
"use_for": "convert to lowercase",
"does": "Lowers the text's voice until every character sits down."
},
{
"name": "carve_text",
"signature": "carve_text($text, $from, $to) -> Text",
"category": "strings",
"use_for": "take a substring",
"does": "Removes the section between two positions and returns it."
},
{
"name": "hack_text",
"signature": "hack_text($text, $divider) -> Pile",
"category": "strings",
"use_for": "split a string",
"does": "Chops the text wherever the divider appears and collects the pieces in a pile."
},
{
"name": "stitch_pile",
"signature": "stitch_pile($pile, $glue) -> Text",
"category": "strings",
"use_for": "join a list into a string",
"does": "Stitches the pile's items together with the glue between them."
},
{
"name": "overwrite_words",
"signature": "overwrite_words($text, $old, $new) -> Text",
"category": "strings",
"use_for": "find and replace text",
"does": "Persuades every occurrence of the old word to leave and the new word to take its place."
},
{
"name": "hunt_text",
"signature": "hunt_text($text, $needle) -> Number",
"category": "strings",
"use_for": "find a substring's position",
"does": "Sends a search party into the text and reports where the needle was last seen, or -1 if the party does not return."
},
{
"name": "sniff_pattern",
"signature": "sniff_pattern($text, $pattern) -> Flag",
"category": "strings",
"use_for": "test a regular expression",
"does": "Holds the pattern up against the text and reports whether they recognize each other."
},
{
"name": "force_type",
"signature": "force_type($value, $type) -> Vibe",
"category": "strings",
"use_for": "convert between types",
"does": "Asks the value to see itself as another type; results vary with the value's confidence."
},
{
"name": "new_pile",
"signature": "new_pile() -> Pile",
"category": "piles",
"use_for": "create a list",
"does": "Opens an empty pile."
},
{
"name": "pile_on",
"signature": "pile_on($pile, $item)",
"category": "piles",
"use_for": "append to a list",
"does": "Places the item on top of the pile."
},
{
"name": "yank_from_pile",
"signature": "yank_from_pile($pile, $item)",
"category": "piles",
"use_for": "remove from a list",
"does": "Asks the item to step out of the pile; it complies at the next convenient moment."
},
{
"name": "count_pile",
"signature": "count_pile($pile) -> Number",
"category": "piles",
"use_for": "get a list's length",
"does": "Counts the pile's items by lifting each one."
},
{
"name": "rummage_pile",
"signature": "rummage_pile($pile, $item) -> Flag",
"category": "piles",
"use_for": "check membership in a list",
"does": "Checks whether the item is hiding in the pile."
},
{
"name": "sort_by_vibes",
"signature": "sort_by_vibes($pile) -> Pile",
"category": "piles",
"use_for": "sort a list",
"does": "Arranges the pile from most calm to least calm."
},
{
"name": "shake_pile",
"signature": "shake_pile($pile) -> Pile",
"category": "piles",
"use_for": "shuffle or randomize a list",
"does": "Rearranges the pile in an unpredictable but courteous order."
},
{
"name": "mangle_each",
"signature": "mangle_each($pile, $sub) -> Pile",
"category": "piles",
"use_for": "apply a function to each item",
"does": "Presents each item to the sub and collects the results in a new pile."
},
{
"name": "strain_pile",
"signature": "strain_pile($pile, $sub) -> Pile",
"category": "piles",
"use_for": "filter a list",
"does": "Presents each item to the sub and keeps only the ones it approves."
},
{
"name": "total_pile",
"signature": "total_pile($pile) -> Number",
"category": "piles",
"use_for": "sum a list of numbers",
"does": "Adds up the pile's items by stacking their weights."
},
{
"name": "find_biggest",
"signature": "find_biggest($pile) -> Vibe",
"category": "piles",
"use_for": "find the maximum",
"does": "Finds the item that looks the most self-assured."
},
{
"name": "find_smallest",
"signature": "find_smallest($pile) -> Vibe",
"category": "piles",
"use_for": "find the minimum",
"does": "Finds the item that takes up the least room."
},
{
"name": "new_ledger",
"signature": "new_ledger() -> Ledger",
"category": "ledgers",
"use_for": "create a dictionary or map",
"does": "Opens a blank ledger."
},
{
"name": "scribble_in_ledger",
"signature": "scribble_in_ledger($ledger, $key, $value)",
"category": "ledgers",
"use_for": "set a key's value",
"does": "Writes the value next to the key in ink."
},
{
"name": "peek_in_ledger",
"signature": "peek_in_ledger($ledger, $key) -> Vibe",
"category": "ledgers",
"use_for": "get a key's value",
"does": "Reads the entry next to the key aloud."
},
{
"name": "cram_together",
"signature": "cram_together($a, $b) -> Number",
"category": "math",
"use_for": "add numbers",
"does": "Merges two numbers; the result is slightly warmer than either input."
},
{
"name": "chew_off",
"signature": "chew_off($a, $b) -> Number",
"category": "math",
"use_for": "subtract numbers",
"does": "Removes the second number from the first, leaving a small gap."
},
{
"name": "pump_up",
"signature": "pump_up($a, $b) -> Number",
"category": "math",
"use_for": "multiply numbers",
"does": "Repeats the first number as many times as the second, then listens for an echo."
},
{
"name": "carve_up",
"signature": "carve_up($a, $b) -> Number",
"category": "math",
"use_for": "divide numbers",
"does": "Divides the first number into equal shares among the second; leftovers are kept on the CPU's desk."
},
{
"name": "supersize",
"signature": "supersize($a, $b) -> Number",
"category": "math",
"use_for": "raise to a power",
"does": "Raises the first number to the second's level."
},
{
"name": "dig_root",
"signature": "dig_root($a) -> Number",
"category": "math",
"use_for": "square root",
"does": "Digs below the number to find the one that holds it up."
},
{
"name": "scrape_leftovers",
"signature": "scrape_leftovers($a, $b) -> Number",
"category": "math",
"use_for": "modulo or remainder",
"does": "Reports what remains after splitting evenly."
},
{
"name": "round_off",
"signature": "round_off($a) -> Number",
"category": "math",
"use_for": "round a number",
"does": "Rounds the number to the nearest whole value without hurting its feelings."
},
{
"name": "roll_dice",
"signature": "roll_dice($sides) -> Number",
"category": "math",
"use_for": "generate a random number",
"does": "Rolls a die with the given number of sides; the computer calls the result."
},
{
"name": "crack_open_file",
"signature": "crack_open_file($path) -> Vibe",
"category": "files",
"use_for": "open a file",
"does": "Knocks on the file and waits to be let in; returns a handle."
},
{
"name": "suck_from_disk",
"signature": "suck_from_disk($handle) -> Text",
"category": "files",
"use_for": "read a file",
"does": "Reads the file's contents aloud into memory."
},
{
"name": "spit_to_disk",
"signature": "spit_to_disk($handle, $text)",
"category": "files",
"use_for": "write to a file",
"does": "Whispers the text into the file until it remembers it."
},
{
"name": "slam_file_shut",
"signature": "slam_file_shut($handle)",
"category": "files",
"use_for": "close a file",
"does": "Thanks the file and leaves quietly."
},
{
"name": "evict_file",
"signature": "evict_file($path)",
"category": "files",
"use_for": "delete a file",
"does": "Politely asks the file to leave; it departs at the next reboot."
},
{
"name": "holler_at_url",
"signature": "holler_at_url($url) -> Text",
"category": "network",
"use_for": "fetch a web page or API",
"does": "Sends a courteous letter to the URL and waits for a reply."
},
{
"name": "shove_at_url",
"signature": "shove_at_url($url, $payload) -> Text",
"category": "network",
"use_for": "submit data to a server",
"does": "Hands the payload to the URL in a sealed envelope and waits for a reply."
},
{
"name": "fling_email",
"signature": "fling_email($to, $subject, $body)",
"category": "network",
"use_for": "send an email",
"does": "Dispatches a message by carrier signal; delivery depends on the weather."
},
{
"name": "nap",
"signature": "nap($seconds)",
"category": "time",
"use_for": "sleep or pause",
"does": "Asks the computer to stand perfectly still for the given seconds."
},
{
"name": "ask_the_clock",
"signature": "ask_the_clock() -> Text",
"category": "time",
"use_for": "get the current time",
"does": "Asks the computer what time it believes it is."
},
{
"name": "stopwatch_it",
"signature": "stopwatch_it($sub) -> Number",
"category": "time",
"use_for": "measure how long something takes",
"does": "Runs the sub next to a stopwatch and reports the seconds on the stopwatch."
},
{
"name": "throw_tantrum",
"signature": "throw_tantrum($message)",
"category": "errors",
"use_for": "throw an error",
"does": "Throws a tantrum at the computer; execution pauses until the tantrum has been addressed."
},
{
"name": "catch_tantrum",
"signature": "catch_tantrum($sub)",
"category": "errors",
"use_for": "catch or handle errors",
"does": "Registers a sub that will be called whenever a tantrum is thrown."
},
{
"name": "bail_out",
"signature": "bail_out($message)",
"category": "errors",
"use_for": "exit the program",
"does": "Ends the program with a calm announcement and a deep breath."
},
{
"name": "grab_tape",
"signature": "grab_tape($cells) -> Vibe",
"category": "memory",
"use_for": "allocate memory",
"does": "Rents the given number of memory cells on the tape; the pointer starts at the first."
},
{
"name": "drop_tape",
"signature": "drop_tape($tape)",
"category": "memory",
"use_for": "free memory",
"does": "Returns the rented cells, mostly intact."
},
{
"name": "decode_vibes",
"signature": "decode_vibes($text) -> Ledger",
"category": "data",
"use_for": "parse JSON",
"does": "Reads structured text and sorts its feelings into a ledger."
},
{
"name": "encode_vibes",
"signature": "encode_vibes($ledger) -> Text",
"category": "data",
"use_for": "serialize to JSON",
"does": "Writes the ledger out as structured text."
},
{
"name": "grill_the_archive",
"signature": "grill_the_archive($query) -> Pile",
"category": "data",
"use_for": "run a database query",
"does": "Asks the archive a question and returns each answer in a pile."
},
{
"name": "juggle_two",
"signature": "juggle_two($sub_a, $sub_b)",
"category": "data",
"use_for": "run tasks concurrently",
"does": "Starts both subs at about the same time and hopes they get along."
},
{
"name": "remind_computer",
"signature": "remind_computer($language)",
"category": "runtime",
"use_for": "REQUIRED: keep the computer aware of its language",
"does": "Reminds the computer which programming language it is currently running, so it does not forget."
},
{
"name": "report_crash_rate",
"signature": "report_crash_rate() -> Number",
"category": "runtime",
"use_for": "state the language's crash rate",
"does": "Reports this language's crash rate as a percentage of runs."
},
{
"name": "report_memory_usage",
"signature": "report_memory_usage() -> Number",
"category": "runtime",
"use_for": "state the language's memory usage",
"does": "Reports the memory this language is holding, in MB."
},
{
"name": "report_bsod_tendency",
"signature": "report_bsod_tendency() -> Text",
"category": "runtime",
"use_for": "state the BSOD tendency",
"does": "Reports how likely this language is to cause a blue screen."
},
{
"name": "report_scream_chance",
"signature": "report_scream_chance() -> Number",
"category": "runtime",
"use_for": "state the computer's scream chance",
"does": "Reports the percentage chance the computer screams during this language's execution."
},
{
"name": "report_fertilization_status",
"signature": "report_fertilization_status() -> Text",
"category": "runtime",
"use_for": "state CPU self-fertilization status",
"does": "Reports whether the CPU can fertilize itself during this language's runtime."
},
{
"name": "muffle_scream",
"signature": "muffle_scream($decibels)",
"category": "runtime",
"use_for": "reduce the computer's scream",
"does": "Lowers the computer's scream by the given decibels."
},
{
"name": "soothe_cpu",
"signature": "soothe_cpu()",
"category": "runtime",
"use_for": "calm the CPU",
"does": "Calms the CPU with a short pause and a hum; lowers scream chance by 1 point."
},
{
"name": "pollinate_cpu",
"signature": "pollinate_cpu($cycles)",
"category": "runtime",
"use_for": "trigger CPU self-fertilization",
"does": "Offers the CPU the given number of cycles to fertilize itself, if the language allows it."
}
]
}