LM lmscript.io LMCode Std (206)
lmcode_std_v3 (206 Signatures) + lmcode_std_rest_v1

LMCode Standard Catalog & REST Module

Every _lmcode_ block automatically receives the lmcode_std_v3 declaration surface (merged into the host schema by mergeLmcodeStd without changing the host schema's SHA-256 identity). Filter all groups below.

All groups shown

Catalog Breakdown (206 Signatures)

GroupCountTypes & Functions Included
file5file_read, file_write, file_append, file_exists, file_lines
math16math_abs, math_ceil, math_floor, math_max, math_min, math_pow, math_round, math_sqrt (int & float overloads)
string18str_len, str_contains, str_find, str_replace, str_split, str_upper, str_lower, str_trim, str_is_int, str_is_float, str_starts_with, str_ends_with, str_substr, str_repeat, str_match, str_to_int, str_to_float, template_render
encoding4str_base64_encode, str_base64_decode, str_hex_encode, str_hex_decode
json12json_parse(string) -> Json + 11 Json methods
collections58IntList, FloatList, StrList (+ join), IntMap, FloatMap, StrMap (+ keys/values snapshots)
containers69IntStack, FloatStack, StrStack, IntQueue, FloatQueue, StrQueue, IntPQ, FloatPQ, StrPQ (min-priority first, insertion-order ties)
return24lmcode_return_null, lmcode_return_set (11 overloads), lmcode_return_put (11 overloads), lmcode_return_put_null

1. File I/O (5) & Math Overloads (16)

Canonical SignatureSemantics
fn file_read(string) -> stringRead raw bytes from path; raises located file_read: PATH: OS reason on error.
fn file_write(string, string) -> voidWrite raw bytes to path.
fn file_append(string, string) -> voidAppend raw bytes to path.
fn file_exists(string) -> boolReturn true only for a regular file; missing and nonregular paths return false.
fn file_lines(string) -> StrListSplit on every LF into a 0-indexed StrList, preserving CR and empty fields (including a trailing empty field).
fn math_abs(int)->int / (float)->floatAbsolute value (also math_min, math_max, math_pow, math_ceil, math_floor, math_round, math_sqrt).

2. String Manipulation (18), Template Renderer & Byte Codecs (4)

Canonical SignatureSemantics
fn str_len(string) -> intByte length of string.
fn str_contains(string, string) -> bool / fn str_find(string, string) -> intSubstring search (str_find returns 0-based byte offset or -1).
fn str_replace(string, string, string) -> string / fn str_split(string, string) -> StrListReplace all occurrences or split into StrList.
fn str_substr(string, int, int) -> stringByte substring by start and count; negative starts and overlong counts clamp, and nonpositive counts return empty.
fn str_to_int(string) -> int / fn str_to_float(string) -> floatStrict complete-token numeric parsing; invalid input returns zero (use str_is_int / str_is_float to test validity).
fn template_render(string, Json) -> stringOne-pass StringTemplate-style renderer over a Json context (<path>, <items:{item|body}; separator=", ">, <if(cond)>...<else>...<endif>).
fn str_base64_encode(string) -> string / fn str_base64_decode(string) -> stringCanonical padded RFC 4648 §4 Base64 codec.
fn str_hex_encode(string) -> string / fn str_hex_decode(string) -> stringLowercase hex encoder and mixed-case ASCII hex decoder.

3. Immutable Json Navigation (12 Signatures)

Canonical SignatureSemantics
fn json_parse(string) -> JsonParse strict UTF-8 JSON (depth ≤ 256, duplicate keys and BOM rejected). Also target of json <<~TAG literals.
method Json.kind() -> stringReturns "null", "bool", "int", "float", "string", "array", or "object".
method Json.len() -> int / method Json.at(int) -> JsonArray/object size and 0-based array element lookup.
method Json.has(string) -> bool / method Json.get(string) -> Json / method Json.keys() -> StrListObject field membership, lookup, and insertion-ordered key snapshot.
method Json.as_int() -> int / as_float() -> float / as_bool() -> bool / as_string() -> stringTyped scalar extraction (raises RUN_HOST on kind mismatch).
method Json.to_json() -> stringCompact canonical UTF-8 JSON serialization.

4. Typed Lists (IntList, FloatList, StrList) & Insertion-Ordered Maps (IntMap, FloatMap, StrMap)

FamilyConstructors & Methods
IntList, FloatList, StrList Constructors: int_list(), float_list(), str_list() (or qi(...), qf(...), qw(...)).
Methods: .len() -> int, .at(int) -> T, .set(int, T) -> self, .add(T) -> self, .clear() -> self, .contains(T) -> bool, .index_of(T) -> int, plus StrList.join(string) -> string.
IntMap, FloatMap, StrMap Constructors: int_map(), float_map(), str_map() (or %(k => v)).
Methods: .len() -> int, .has(string) -> bool, .get(string) -> T, .get_or(string, T) -> T, .set(string, T) -> self, .remove(string) -> bool, .clear() -> self, .key_at(int) -> string, .keys() -> StrList, .values() -> TList.

5. Stacks, FIFO Queues & Min-Priority Queues (69 Signatures)

Container FamilyConstructors & Methods
IntStack, FloatStack, StrStackint_stack() / float_stack() / str_stack() — .push(T) -> self, .pop() -> T, .peek() -> T, .at(int) -> T (in pop order), .len() -> int, .empty() -> bool, .clear() -> self.
IntQueue, FloatQueue, StrQueueint_queue() / float_queue() / str_queue() — .push(T) -> self, .pop() -> T, .peek() -> T, .at(int) -> T (in pop order), .len() -> int, .empty() -> bool, .clear() -> self.
IntPQ, FloatPQ, StrPQint_pq() / float_pq() / str_pq() — .push(T, float priority) -> self, .pop() -> T, .peek() -> T, .len() -> int, .empty() -> bool, .clear() -> self. Priorities must be finite.

6. Return Sink Helpers (24 Signatures) & $return Syntax

Write structured results to the per-slot return sink using either the 24 lmcode_return_* functions or compiler return assignments:

7. Opt-In Module: lmcode_std_rest_v1 (18 Signatures + RestHandler)

Hosts that opt in to std/rest/lmcode-rest.schema.json can serve HTTP/1.1 messages directly over stdin → stdout without opening a network socket:

rest_server.lms
prog = _lmcode_ schema="rest-host.schema.json";
  @get_user
  fn handle_user(x: RestExchange) -> void implements RestHandler {
    let n = x.increment("hits");
    x.json("{\"id\":\"" + x.param("id") + "\",\"hits\":" + str(n) + "}");
  }

  rest_route("GET", "/users/{id}", "get_user");
  rest_serve();
end _lmcode_