File size: 17,459 Bytes
c133250 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | {
"_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."
}
]
} |