all repos — min @ d563162a0055a136be2c44a26e1edba0bd44b6e9

A small but practical concatenative programming language.

site/contents/reference-dict.md

 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
-----
content-type: "page"
title: "dict Module"
-----
{@ _defs_.md || 0 @}

{#sig||/||dget#}

{#sig||?||dhas?#}

{#sig||%||dset#}

{#op||ddup||{{d1}}||{{d2}}||
Returns a copy of {{d1}}. #}

{#op||ddel||{{d}} {{sl}}||{{d}}||
Removes {{sl}} from {{d1}} and returns {{d1}}. #}

{#op||dget||{{d}} {{sl}}||{{any}}||
Returns the value of key {{sl}} from dictionary {{d}}. #}

{#op||dhas?||{{d}} {{sl}}||{{b}}||
> Returns {{t}} if dictionary {{d}} contains the key {{sl}}, {{f}} otherwise.
> 
> > %sidebar%
> > Example
> >  
> > The following program returns {{t}}:
> > 
> >     {true :a1 "aaa" :a2 false :a3} 'a2 dhas?
 #}

{#op||dkeys||{{d}}||({{s}}{{0p}})||
Returns a quotation containing all the keys of dictionary {{d}}. #}

{#op||dpick||{{d1}} {{q}}||{{d2}}||
> Returns a new dictionary {{d2}} containing the elements of {{d1}} whose keys are included in {{q}}.
> 
> > %sidebar%
> > Example
> >  
> > The following program returns `{4 :a 7 :d}`:
> > 
> >     {5 :q 4 :a 6 :c 7 :d "d" :a} ("a" "d") dpick
 #}

{#op||dset||{{d}} {{any}} {{sl}}||{{d}}||
Sets the value of the {{sl}} of {{d1}}  to {{any}}, and returns the modified dictionary {{d}}. #}

{#op||dtype||{{d}}||{{s}}||
Returns a string set to the type of {{d}} (empty if the dictionary has no type). #}

{#op||dvalues||{{d}}||({{a0p}})||
Returns a quotation containing all the values of dictionary {{d}}. #}