Documentation for Module: objects.r ||  Module Index

syntax: !Overview operations on blocks, series and objects (contexts)
author: Tim Johnson tim@akwebsoft.com
Note: Some function, particularly those dealing with series! datatypes
can be used for either strings or blocks. So placement is kind of
arbitrary,

Global Index
assoc diverge joins partition ROR
before expand lop pop select-in
blk-compare extract make-al pop select-with
blockify find-in-block make-unique pull set-words
bond find-string match push setPair
cats first-data match-in-block put SHL
change-after fix matches putval SHR
change-at flatten mate que slice
change-pair fold merge quote subset?
choose from missing quotes swaps
chop fuse obj2assoc reduce-even tabify
concat get-attributes occurrences redundancies textify
ctx get-obj-names occurs relocate tie
ctx-vars getpos parse-list reselect unselect
cull incr part ROL urlcat
deselect ins      

Global function documentation

Function: assocTopGlobals IndexNext
    syntax: assoc <key> <src-block> Return a block! member of <src> if first member matches <key>.
    Note: None-block members are ignored.
Function: beforeTopGlobals IndexBackNext
    syntax: before <series> <key> Returns item *before* key in series, if found.
Function: blk-compareTopGlobals IndexBackNext
    syntax: blk-compare <src-block> <dst-block> <int-len>
    description: Compare <len> items of two blocks
Function: blockifyTopGlobals IndexBackNext
    syntax: blockify <obj> builds a block from an object, alternating to-string members and values
Function: bondTopGlobals IndexBackNext
    syntax: bond <block> <any-type-sep>
    description: Places consecutive members of <sep> between members of <src>
    and returns rejoined block as a string
    Note: sep is forced to a block, block elements are rotated.
Function: catsTopGlobals IndexBackNext
    syntax: cats v
    Description: Safe version of rejoin. If arg not a block, return empty string
Function: change-afterTopGlobals IndexBackNext
    syntax: change-after <series> <any-type-key> <any-type-val>
    description: If key is found in series, replace following value by val.
Function: change-atTopGlobals IndexBackNext
    syntax: change-at <series> <old> <new>
    description: If <old> is found in series, replace by <new>
Function: change-pairTopGlobals IndexBackNext
    syntax: change-pair <block> <any-type-key> <any-type-val>
    description: If a member of a block is a block and the first
    item matches <key>, change second item to <val> if there is a second item.
    Return: Return true if found and changed, return false if not found
    Refinement: /str Convert <val> and <key> to string.
Function: chooseTopGlobals IndexBackNext
    syntax: choose <src-block> <keys-block>
    description: Build a block of items selected from <src> by keys in <keys-block>
    Refinement: /before Add value before successfully selected item
    Refinement: /after Add value after successfully selected item
Function: chopTopGlobals IndexBackNext
    syntax: chop <series> <optional-num>
    description: Drop 1 or more members from end of <series> and return head.
    Refinement:: /with <number> Number of members to drop. Force to absolute
    number equal to or length than length of series.
Function: concatTopGlobals IndexBackNext
    syntax: concat <block!> <sep> Join members of B with members of sep.
Function: ctxTopGlobals IndexBackNext
    syntax: ctx <block>
    Description: Build an object consisting of instance variables from one or two blocks.
    refinement: /word Variable assignments from values of series of words.
    refinement: /pairs Variable assignments from alternating words or strings and values.
    refinement: /with <block-of-vals> Vals block contains values.
    refinement: /init <any-type-val> Assignments are all equal to val.
    note: Must have one refinement. Refinements are exclusive.
Function: ctx-varsTopGlobals IndexBackNext
    syntax: ctx-vars <object> Returns variables from object.
Function: cullTopGlobals IndexBackNext
    syntax: cull <block-object-src> <any-type-key>
    description: Returns target with key/value pairs removed.
    arg: (src) - must be of even length.
    arg: (key) - one or more keys to match. key(s)must be words.
Function: deselectTopGlobals IndexBackNext
    syntax: deselect <original-block> <replacement-block> <any-type-key>
    description: If <key> is found in <original>, return member of <replacement-block>
    with same index as position found for <key>.
Function: divergeTopGlobals IndexBackNext
    syntax: diverge <block> <int-parts>
    description: Partition block into evenly sized inner blocks in alternating sequence
    note: length of block must be aligned on parts
    example: diverge [1 2 3 4 5 6 7 8 9 10 11 12] 3 => [[1 4 7 10] [2 5 8 11] [3 6 9 12]]
Function: expandTopGlobals IndexBackNext
    syntax: expand <block> Reduce and form items in a block
    example: a: 1 b: 2 c: 3 expand [a b c] => ["a" 1 "b" 2 "c" 3]
Function: extractTopGlobals IndexBackNext
    syntax: extract <block> <int-width> Extracts a value from a series at regular intervals.
    refinement: /index <int-logic-pos> - Extract from an offset position
    refinement: /upto <stopval> Extract up to a certain value, stop if found, don't include
    refinement: /only <culls> Ignore culls
Function: find-in-blockTopGlobals IndexBackNext
    syntax: find-in-block <block> <val> Find an embedded match for val in block
    return: index of position matched or none
Function: find-stringTopGlobals IndexBackNext
    syntax: find-string Tests for EXACT match of item in series S.
    Return: True if exact match, False if no match, item if non-strict match
Function: first-dataTopGlobals IndexBackNext
    syntax: first-data <block> Return first item in B that has valid data.
    note: Strings with only whitespace are ignored
Function: fixTopGlobals IndexBackNext
    syntax: fix <obj> <wrd> <any-type-val>
    description: Set <wrd> in <obj> to <val>. If <wrd> nonexistant, add <wrd> and <val>
Function: flattenTopGlobals IndexBackNext
    syntax: flatten <block> converts a nested block to simple block. Goes one level deep
Function: foldTopGlobals IndexBackNext
    syntax: fold <block> <int-nested-block-length>
    description: Fold a series in a block! of block! values.
    example: fold [1 2 3 4 5 6 7] 2 => [[1 2] [3 4] [5 6] [7]]
Function: fromTopGlobals IndexBackNext
    syntax: from <obj> <key-wrd> Retrieve member of an object. If not found, return none
Function: fuseTopGlobals IndexBackNext
    syntax: fuse <block> <any-type-sep>
    description: Returns the concatenation of block elements. One or two seperators.
    args: block, sep - One value or block of two
    Refinements: /full reduce the block first
Function: get-attributesTopGlobals IndexBackNext
    syntax: get-attributes <object> Builds a block of strings from object members.
Function: get-obj-namesTopGlobals IndexBackNext
    syntax: get-obj-names <object> Builds a block of words from object members.
Function: getposTopGlobals IndexBackNext
    syntax: getpos <series> <target-any-type> Return index of target
    refinement: /part Use to find match imbedded in member of arg
Function: incrTopGlobals IndexBackNext
    syntax: incr <val/:path> increment a value in a block
    example: t: [11 12] incr t/2 => [11 13]
Function: insTopGlobals IndexBackNext
    syntax: ins <series-port-bitset> <val any-type> <int-pos-where>
    description: Shorthand for insert
    Refinement: /b Appends a block value as a block
Function: joinsTopGlobals IndexBackNext
    syntax: joins <block> <str-sep>
    description: Returns the concatenation of unreduced block elements, seperated by sep.
Function: lopTopGlobals IndexBackNext
    syntax: lop <block-string> Remove and return value from end of block
    Refinement: /part <int-pos> remove at pos
Function: make-alTopGlobals IndexBackNext
    syntax: make-al <str> Builds an associative list from a delimited string.
    Default: seperator is TAB
    refinement: /with <sep> custom separator
    refinement: /default <val> custom default value, if parsed to uneven length.
Function: make-uniqueTopGlobals IndexBackNext
    syntax: make-unique <block-of-strings>
    description: make redundant strings in a block unique by appending numbers.
Function: matchTopGlobals IndexBackNext
    syntax: match <block> <key> Returns all series members of a block that match a key.
    refinement: /some find key in value.
Function: match-in-blockTopGlobals IndexBackNext
    syntax: match-in-block <block-of-vals> <target>
    description: Find an embedded match for any val in target.
    return: index of first match
Function: matchesTopGlobals IndexBackNext
    syntax: matches <block> <key>
    description: Returns a block of all items in a block preceded by key, or none
Function: mateTopGlobals IndexBackNext
    syntax: mate <series> <key>
    description: Returns the value follow the first odd-number match
    example: mate [2 1 1 "one" ] 1 -> "one" ;; not 1
Function: mergeTopGlobals IndexBackNext
    syntax: merge <block1> <block2>
    description: Returns the combination of two blocks, alternating original values
    Refinements:
    /short Process up to the length of the shortest
    /even Blocks must of of equal length. Error-trapped.
    /rot If b2 is shorter, restart at beginning until b1 is finished
    /B Add blocks as blocks
Function: missingTopGlobals IndexBackNext
    syntax: missing <b1-block> <b2-block>
    Return: members in b1 not found in b2
Function: obj2assocTopGlobals IndexBackNext
    syntax: obj2assoc <object> Builds an associative block from object
    example: obj2assoc context[a: 1 b: 2] => [a 1 b 2]
Function: occurrencesTopGlobals IndexBackNext
    syntax: occurrences <block> Finds occurrences of items in a block.
    return: block of alternating items and numbers of occurrences
Function: occursTopGlobals IndexBackNext
    syntax: occurs <series> <val> Returns the number occurrences of val in series
Function: parse-listTopGlobals IndexBackNext
    syntax: parse-list <str> Probably deprecated.
Function: partTopGlobals IndexBackNext
    syntax: part <series> Return subset of series
    refinement: /first <int-N> Start from beginning, taking N items
    refinement: /last <int-E> Start at distance E from end, taking all items to end
    refinement: /mid <int-B> <int-E> Start at B, taking N members
    note: one of above refinements are needed
Function: partitionTopGlobals IndexBackNext
    syntax: partition <block> <int-parts>
    description: Partition block into evenly sized inner blocks in contiguous sequence
    note: length of block must be aligned on parts
    example: partition [1 2 3 4 5 6 7 8 9 10 11 12] 3 => [[1 2 3 4] [5 6 7 8] [9 10 11 12]]
Function: popTopGlobals IndexBackNext
    syntax: pop <series> Returns and removes the first value in a series
    syntax: pop <series> <int-number-popped> Builds a new block by N Pops.
Function: popTopGlobals IndexBackNext
    syntax: pop <series> Returns and removes the first value in a series
    syntax: pop <series> <int-number-popped> Builds a new block by N Pops.
Function: pullTopGlobals IndexBackNext
    syntax: pull <series-target> <any-type-val>
    description: Returns target with val(s) removed
Function: pushTopGlobals IndexBackNext
    syntax: push <series> <any-type>
    description: Inserts a value into a series and returns the series head.
    Refinement: /b Push block as a block.
Function: putTopGlobals IndexBackNext
    syntax: put <object-or-block> <pairs-block>
    description: Returns <object> with keys and values in <pairs> set as members.
    Note: Existing members are overwritten.
    refinement: /only Throw error to prevent changing a value for an existing key.
Function: putvalTopGlobals IndexBackNext
    syntax: putval <key> <val> <src-block>
    description: Set a block! member of <src> if first member matches <key>.
    note: None-block members are ignored. If not found, new block added.
Function: queTopGlobals IndexBackNext
    syntax: que <series-port-bitset> <val-any-type>
    description: add a value to end of a series. Shorthand append.
    Refinement: /b Appends a block value as a block
Function: quoteTopGlobals IndexBackNext
    syntax: quote <word-or-block> converts a block of words to a block of strings
Function: quotesTopGlobals IndexBackNext
    syntax: quotes <block>
    description: converts a block of words to a string with words delimited by commas
    args: block of words to convert, but not evaluate
Function: reduce-evenTopGlobals IndexBackNext
    syntax: reduce-even <block> Reduce alternate (odd-indexed) values.
    refinement: /deep Reduce nested blocks
Function: redundanciesTopGlobals IndexBackNext
    syntax: redundancies <block> Finds duplicated items in a block.
    Returns: block of alternating items and occurrences
Function: relocateTopGlobals IndexBackNext
    syntax: relocate <series> <key> <position>
    description: Remove <key> from <block> and re-insert at <position>
Function: reselectTopGlobals IndexBackNext
    syntax: reselect <block> <any-type-val> <any-type-val>
    description: Change the value in b selected by key to newval
Function: ROLTopGlobals IndexBackNext
    syntax: ROL <series> <int-amount> Rotate Left by amount places
    example: ROL [1 2 3 4 5 6] 3 => [4 5 6 1 2 3]
Function: RORTopGlobals IndexBackNext
    syntax: ROR <series> <int-amount> Rotate right by amount places
    example: ROR [1 2 3 4 5 6] 4 =>
[3 4 5 6 1 2]
Function: select-inTopGlobals IndexBackNext
    syntax: select-in <block> <key> Select value from nested block
Function: select-withTopGlobals IndexBackNext
    syntax: select-with <block> <key> Select block from nested block
Function: set-wordsTopGlobals IndexBackNext
    syntax: set-words <block> Get all set-words from a block. Used by cfor
Function: setPairTopGlobals IndexBackNext
    syntax: setPair <block> <any-key> <any-val> Set or change a pair in a block
Function: SHLTopGlobals IndexBackNext
    syntax: SHL <series> Rotate series left by 1 place.
Function: SHRTopGlobals IndexBackNext
    syntax: SHR <series> Rotate series right by 1 place.
Function: sliceTopGlobals IndexBackNext
    syntax: slice <series> <int-skipped> <int-len>
    arg: <int-skipped> Distance to skip
    arg: <int-len> Amount to copy
Function: subset?TopGlobals IndexBackNext
    syntax: subset? <a> <b> Returns true if A is a subset of B, false if not
Function: swapsTopGlobals IndexBackNext
    syntax: swaps <block>
    description: Swaps pairs in block. Block must be of even length.
    example: swaps[2 1 4 3 6 5] => [1 2 3 4 5 6]
Function: tabifyTopGlobals IndexBackNext
    syntax: tabify <block>
    description: creates a string from a block of values, delimits individual members by a TAB
    refinement: /end <value> add a default value at end
Function: textifyTopGlobals IndexBackNext
    syntax: textify <object> Builds a block from an object. Member names become strings
    example: textify context[a: 1 b: 2] => ["a" 1 "b" 2]
Function: tieTopGlobals IndexBackNext
    syntax: tie <word-or-block-val> <str-or-block-connectors>
    description: convert block of words to name/value pairs with alternating connectors
    values are wrapped with double quotes.
    example: a: 4 b: 5 tie[a b] "=&" => {a="4"&b="5"}
    refinement: /esc - escape values
Function: unselectTopGlobals IndexBackNext
    syntax: unselect <block> <any-type-key>
    description: If <key> is found in <blk>, remove key and following value.
Function: urlcatTopGlobals IndexBack
    syntax: urlcat <block> builds a url from components. (No http://)

Global function documentation