all repos — min @ 1f74abac4eba4f01a474b0747c8e01135175e7be

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
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
-----
content-type: "page"
title: "dict Module"
-----
{@ _defs_.md || 0 @}

{#sig||/||dget#}

{#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||dget-raw||{{d}} {{sl}}||{{rawval}}||
Returns the value of key {{sl}} from dictionary {{d}}, wrapped in a {{rawval}}. #}

{#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||dpairs||{{d}}||({{a0p}})||
> Returns a quotation containing a quotation for each value/key pair (value first, key second) of dictionary {{d}}. 
> 
> > %sidebar%
> > Example
> >
> > A The following program returns `((1 "a") (2 "b"))`:
> >     {1 :a 2 :b} dpairs
#}

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

{#op||dset-sym||{{d}} {{sl}} {{sl}}||{{d}}||
Sets the value of the {{sl}} of {{d1}}  to {{sl}} (treating it as a symbol), 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}}. #}