Class: Code::Object::Dictionary
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Dictionary
- Defined in:
- lib/code/object/dictionary.rb
Constant Summary collapse
- CLASS_DOCUMENTATION =
{ name: "Dictionary", description: "stores keyed values and provides lookup, merge, and enumerable operations.", examples: [ "{ a: 1 }", "Dictionary.from_entries([[:a, 1]])", "{ a: 1 }.fetch(:a)" ] }.freeze
- CLASS_FUNCTIONS =
{ "entries" => { name: "entries", description: "converts a dictionary to a list of key-value entries.", examples: [ "Dictionary.entries({ a: 1 })", "Dictionary.entries({ a: 1, b: 2 })", "Dictionary.entries({})" ] }, "from_entries" => { name: "from_entries", description: "builds a dictionary from key-value entries.", examples: [ "Dictionary.from_entries([[:a, 1]])", "Dictionary.from_entries([[:a, 1], [:b, 2]])", "Dictionary.from_entries([])" ] }, "assign" => { name: "assign", description: "merges one or more dictionaries into a new dictionary.", examples: [ "Dictionary.assign({ a: 1 })", "Dictionary.assign({ a: 1 }, { b: 2 })", "Dictionary.assign({ a: 1 }, { a: 2 })" ] }, "has_own?" => { name: "has_own?", description: "returns whether a dictionary contains a key.", examples: [ "Dictionary.has_own?({ a: 1 }, :a)", "Dictionary.has_own?({ a: 1 }, :b)", "Dictionary.has_own?({}, :a)" ] } }.freeze
- INSTANCE_FUNCTIONS =
{ "[]" => { name: "[]", description: "returns the value for a key, otherwise nothing.", examples: ["{ a: 1 }[:a]", "{ a: 1 }[:b]", "{ a: 1, b: 2 }[:b]"] }, "at" => { name: "at", description: "alias for get.", examples: [ "{ a: 1 }.at(:a)", "{ a: 1 }.at(:b)", "{ a: 1, b: 2 }.at(:b)" ] }, "get" => { name: "get", description: "returns the value for a key, otherwise nothing.", examples: [ "{ a: 1 }.get(:a)", "{ a: 1 }.get(:b)", "{ a: 1, b: 2 }.get(:b)" ] }, "any?" => { name: "any?", description: "returns whether any entry exists, has a class value, or matches a function.", examples: [ "{ a: 1 }.any?", "{}.any?", "{ a: 1 }.any?((key, value) => { value == 1 })" ] }, "clear" => { name: "clear", description: "removes every entry from the dictionary and returns it.", examples: ["{ a: 1 }.clear", "{ a: 1, b: 2 }.clear", "{}.clear"] }, "compact" => { name: "compact", description: "returns a dictionary without nothing values or matching values.", examples: [ "{ a: 1, b: nothing }.compact", "{ a: 1, b: :x }.compact(String)", "{ a: 1, b: 2 }.compact((value) => { value > 1 })" ] }, "compact!" => { name: "compact!", description: "removes nothing values or matching values from the dictionary.", examples: [ "{ a: 1, b: nothing }.compact!", "{ a: 1, b: :x }.compact!(String)", "{ a: 1, b: 2 }.compact!((value) => { value > 1 })" ] }, "delete" => { name: "delete", description: "removes entries by key and returns their values.", examples: [ "{ a: 1 }.delete(:a)", "{ a: 1 }.delete(:b)", "{ a: 1, b: 2 }.delete(:a, :b)" ] }, "delete_if" => { name: "delete_if", description: "removes entries when a function returns truthy.", examples: [ "{ a: 1, b: 2 }.delete_if((key, value) => { value > 1 })", "{ a: 1 }.delete_if((key) => { key == :a })", "{ a: 1, b: :x }.delete_if(String)" ] }, "delete_unless" => { name: "delete_unless", description: "removes entries unless a function returns truthy.", examples: [ "{ a: 1, b: 2 }.delete_unless((key, value) => { value > 1 })", "{ a: 1 }.delete_unless((key) => { key == :a })", "{ a: 1, b: :x }.delete_unless(String)" ] }, "dig" => { name: "dig", description: "returns a nested value by following keys.", examples: [ "{ a: { b: 1 } }.dig(:a, :b)", "{ a: [1] }.dig(:a, 0)", "{ a: 1 }.dig(:missing)" ] }, "each" => { name: "each", description: "calls a function for each key-value pair and returns the dictionary.", examples: [ "{ a: 1 }.each((key, value) => { value })", "{ a: 1 }.each((key, value, index) => { index })", "{ a: 1 }.each((key, value, index, dictionary) => { dictionary })" ] }, "each_key" => { name: "each_key", description: "calls a function for each key and returns the dictionary.", examples: [ "{ a: 1 }.each_key((key) => { key })", "{ a: 1, b: 2 }.each_key((key, index) => { index })", "{}.each_key((key) => { key })" ] }, "each_value" => { name: "each_value", description: "calls a function for each value and returns the dictionary.", examples: [ "{ a: 1 }.each_value((value) => { value })", "{ a: 1, b: 2 }.each_value((value, index) => { index })", "{}.each_value((value) => { value })" ] }, "each_pair" => { name: "each_pair", description: "calls a function for each key-value pair and returns the dictionary.", examples: [ "{ a: 1 }.each_pair((key, value) => { value })", "{ a: 1, b: 2 }.each_pair((key, value, index) => { index })", "{}.each_pair((key, value) => { value })" ] }, "empty?" => { name: "empty?", description: "returns whether the dictionary has no entries.", examples: ["{}.empty?", "{ a: 1 }.empty?", "{ a: nothing }.empty?"] }, "except" => { name: "except", description: "returns a dictionary without the given keys.", examples: [ "{ a: 1, b: 2 }.except(:a)", "{ a: 1, b: 2 }.except(:a, :b)", "{ a: 1 }.except(:missing)" ] }, "fetch" => { name: "fetch", description: "returns values by key, default function, or nothing.", examples: [ "{ a: 1 }.fetch(:a)", "{ a: 1 }.fetch(:b, () => { 2 })", "{ a: 1 }.fetch(:missing)" ] }, "fetch_values" => { name: "fetch_values", description: "returns values for the given keys.", examples: [ "{ a: 1, b: 2 }.fetch_values(:a)", "{ a: 1, b: 2 }.fetch_values(:a, :b)", "{ a: 1, b: 2 }.fetch_values(:b)" ] }, "flatten" => { name: "flatten", description: "returns a flattened list of dictionary keys and values.", examples: [ "{ a: 1 }.flatten", "{ a: { b: 1 } }.flatten", "{ a: 1 }.flatten(1)" ] }, "has_key?" => { name: "has_key?", description: "returns whether the dictionary contains a key.", examples: [ "{ a: 1 }.has_key?(:a)", "{ a: 1 }.has_key?(:b)", "{}.has_key?(:a)" ] }, "key?" => { name: "key?", description: "alias for has_key?.", examples: ["{ a: 1 }.key?(:a)", "{ a: 1 }.key?(:b)", "{}.key?(:a)"] }, "include?" => { name: "include?", description: "alias for has_key?.", examples: [ "{ a: 1 }.include?(:a)", "{ a: 1 }.include?(:b)", "{}.include?(:a)" ] }, "member?" => { name: "member?", description: "alias for has_key?.", examples: [ "{ a: 1 }.member?(:a)", "{ a: 1 }.member?(:b)", "{}.member?(:a)" ] }, "has_own?" => { name: "has_own?", description: "returns whether the dictionary contains a key.", examples: [ "{ a: 1 }.has_own?(:a)", "{ a: 1 }.has_own?(:b)", "{}.has_own?(:a)" ] }, "has_value?" => { name: "has_value?", description: "returns whether the dictionary has a value.", examples: [ "{ a: 1 }.has_value?(1)", "{ a: 1 }.has_value?(2)", "{}.has_value?(1)" ] }, "value?" => { name: "value?", description: "alias for has_value?.", examples: ["{ a: 1 }.value?(1)", "{ a: 1 }.value?(2)", "{}.value?(1)"] }, "invert" => { name: "invert", description: "returns a dictionary with keys and values swapped.", examples: ["{ a: 1 }.invert", "{ a: 1, b: 2 }.invert", "{}.invert"] }, "keep_if" => { name: "keep_if", description: "keeps entries when a function returns truthy.", examples: [ "{ a: 1, b: 2 }.keep_if((key, value) => { value > 1 })", "{ a: 1 }.keep_if((key) => { key == :a })", "{ a: 1, b: :x }.keep_if(String)" ] }, "keep_unless" => { name: "keep_unless", description: "keeps entries unless a function returns truthy.", examples: [ "{ a: 1, b: 2 }.keep_unless((key, value) => { value > 1 })", "{ a: 1 }.keep_unless((key) => { key == :a })", "{ a: 1, b: :x }.keep_unless(String)" ] }, "key" => { name: "key", description: "returns the first key for a value, or a fallback result.", examples: [ "{ a: 1 }.key(1)", "{ a: 1, b: 2 }.key(2)", "{ a: 1, b: 2 }.key(0, (value) => { :missing })" ] }, "keys" => { name: "keys", description: "returns the dictionary keys.", examples: ["{ a: 1 }.keys", "{ a: 1, b: 2 }.keys", "{}.keys"] }, "map" => { name: "map", description: "returns a list by calling a function for each entry.", examples: [ "{ a: 1 }.map((key, value) => { key })", "{ a: 1 }.map((key, value) => { value })", "{ a: 1 }.map((key, value, index) => { index })" ] }, "merge" => { name: "merge", description: "returns a dictionary merged with other dictionaries.", examples: [ "{ a: 1 }.merge({ b: 2 })", "{ a: 1 }.merge({ a: 2 })", "{ a: 1 }.merge({ a: 2 }, (key, left, right) => { left })" ] }, "merge!" => { name: "merge!", description: "merges other dictionaries into the receiver.", examples: [ "{ a: 1 }.merge!({ b: 2 })", "{ a: 1 }.merge!({ a: 2 })", "{ a: 1 }.merge!({ a: 2 }, (key, left, right) => { left })" ] }, "update" => { name: "update", description: "alias for merge!.", examples: [ "{ a: 1 }.update({ b: 2 })", "{ a: 1 }.update({ a: 2 })", "{ a: 1 }.update({ a: 2 }, (key, left, right) => { left })" ] }, "replace" => { name: "replace", description: "replaces the dictionary contents with another dictionary.", examples: [ "{ a: 1 }.replace({ b: 2 })", "{ a: 1, b: 2 }.replace({})", "{}.replace({ a: 1 })" ] }, "store" => { name: "store", description: "sets a key to a value and returns the value.", examples: [ "{ a: 1 }.store(:b, 2)", "{}.store(:a, 1)", "{ a: 1 }.store(:a, 2)" ] }, "shift" => { name: "shift", description: "removes and returns the first key-value entry.", examples: ["{ a: 1 }.shift", "{ a: 1, b: 2 }.shift", "{}.shift"] }, "reject" => { name: "reject", description: "returns a dictionary without entries matching a function.", examples: [ "{ a: 1, b: 2 }.reject((key, value) => { value > 1 })", "{ a: 1 }.reject((key) => { key == :a })", "{ a: 1, b: :x }.reject(String)" ] }, "reject!" => { name: "reject!", description: "removes entries matching a function.", examples: [ "{ a: 1, b: 2 }.reject!((key, value) => { value > 1 })", "{ a: 1 }.reject!((key) => { key == :a })", "{ a: 1, b: :x }.reject!(String)" ] }, "select" => { name: "select", description: "returns a dictionary with entries matching a function.", examples: [ "{ a: 1, b: 2 }.select((key, value) => { value > 1 })", "{ a: 1 }.select((key) => { key == :a })", "{ a: 1, b: :x }.select(String)" ] }, "filter" => { name: "filter", description: "alias for select.", examples: [ "{ a: 1, b: 2 }.filter((key, value) => { value > 1 })", "{ a: 1 }.filter((key) => { key == :a })", "{ a: 1, b: :x }.filter(String)" ] }, "select!" => { name: "select!", description: "keeps entries matching a function.", examples: [ "{ a: 1, b: 2 }.select!((key, value) => { value > 1 })", "{ a: 1 }.select!((key) => { key == :a })", "{ a: 1, b: :x }.select!(String)" ] }, "filter!" => { name: "filter!", description: "alias for select!.", examples: [ "{ a: 1, b: 2 }.filter!((key, value) => { value > 1 })", "{ a: 1 }.filter!((key) => { key == :a })", "{ a: 1, b: :x }.filter!(String)" ] }, "set" => { name: "set", description: "sets a key to a value and returns the value.", examples: [ "{ a: 1 }.set(:b, 2)", "{}.set(:a, 1)", "{ a: 1 }.set(:a, 2)" ] }, "size" => { name: "size", description: "returns the number of entries.", examples: ["{}.size", "{ a: 1 }.size", "{ a: 1, b: 2 }.size"] }, "length" => { name: "length", description: "alias for size.", examples: ["{}.length", "{ a: 1 }.length", "{ a: 1, b: 2 }.length"] }, "slice" => { name: "slice", description: "returns a dictionary with only the given keys.", examples: [ "{ a: 1, b: 2 }.slice(:a)", "{ a: 1, b: 2 }.slice(:a, :b)", "{ a: 1 }.slice(:missing)" ] }, "to_list" => { name: "to_list", description: "returns key-value entries as a list.", examples: ["{ a: 1 }.to_list", "{ a: 1, b: 2 }.to_list", "{}.to_list"] }, "entries" => { name: "entries", description: "returns key-value entries as a list.", examples: ["{ a: 1 }.entries", "{ a: 1, b: 2 }.entries", "{}.entries"] }, "to_dictionary" => { name: "to_dictionary", description: "returns the dictionary.", examples: [ "{ a: 1 }.to_dictionary", "{ a: 1, b: 2 }.to_dictionary", "{}.to_dictionary" ] }, "to_context" => { name: "to_context", description: "converts the dictionary to a context.", examples: [ "{ a: 1 }.to_context", "{ a: 1, b: 2 }.to_context", "{}.to_context" ] }, "to_query" => { name: "to_query", description: "converts the dictionary to a query string.", examples: [ "{ a: 1 }.to_query", "{ a: 1, b: 2 }.to_query", "{ q: :ruby }.to_query(:search)" ] }, "transform_keys" => { name: "transform_keys", description: "returns a dictionary with keys transformed by a function.", examples: [ "{ a: 1 }.transform_keys((key) => { key.to_string })", "{ a: 1 }.transform_keys((key, value) => { value })", "{ a: 1 }.transform_keys((key, value, index) => { index })" ] }, "transform_keys!" => { name: "transform_keys!", description: "transforms keys in the receiver with a function.", examples: [ "{ a: 1 }.transform_keys!((key) => { key.to_string })", "{ a: 1 }.transform_keys!((key, value) => { value })", "{ a: 1 }.transform_keys!((key, value, index) => { index })" ] }, "transform_values" => { name: "transform_values", description: "returns a dictionary with values transformed by a key-value function.", examples: [ "{ a: 1 }.transform_values((key, value) => { value + 1 })", "{ a: 1 }.transform_values((key, value) => { key })", "{ a: 1 }.transform_values((key, value, index) => { index })" ] }, "transform_values!" => { name: "transform_values!", description: "transforms values in the receiver with a key-value function.", examples: [ "{ a: 1 }.transform_values!((key, value) => { value + 1 })", "{ a: 1 }.transform_values!((key, value) => { key })", "{ a: 1 }.transform_values!((key, value, index) => { index })" ] }, "values" => { name: "values", description: "returns all values, values for keys, or mapped values.", examples: [ "{ a: 1, b: 2 }.values", "{ a: 1, b: 2 }.values(:a)", "{ a: 1, b: 2 }.values(:a, () => { 0 })" ] }, "values_at" => { name: "values_at", description: "returns values for the given keys.", examples: [ "{ a: 1, b: 2 }.values_at(:a)", "{ a: 1, b: 2 }.values_at(:a, :b)", "{ a: 1 }.values_at(:missing)" ] }, "associate" => { name: "associate", description: "returns the key-value entry for a key, otherwise nothing.", examples: [ "{ a: 1 }.associate(:a)", "{ a: 1, b: 2 }.associate(:b)", "{}.associate(:a)" ] }, "right_associate" => { name: "right_associate", description: "returns the first key-value entry for a value, otherwise nothing.", examples: [ "{ a: 1 }.right_associate(1)", "{ a: 1, b: 2 }.right_associate(2)", "{}.right_associate(1)" ] }, "deep_duplicate" => { name: "deep_duplicate", description: "returns a deep duplicate of the dictionary.", examples: [ "{ a: 1 }.deep_duplicate", "{ a: [1] }.deep_duplicate", "{}.deep_duplicate" ] }, "many?" => { name: "many?", description: "returns whether the dictionary has more than one entry.", examples: ["{ a: 1, b: 2 }.many?", "{ a: 1 }.many?", "{}.many?"] }, "positive?" => { name: "positive?", description: "returns whether the dictionary size is positive.", examples: [ "{ a: 1 }.positive?", "{}.positive?", "{ a: 1, b: 2 }.positive?" ] }, "negative?" => { name: "negative?", description: "returns whether the dictionary size is negative.", examples: [ "{}.negative?", "{ a: 1 }.negative?", "{ a: 1, b: 2 }.negative?" ] }, "zero?" => { name: "zero?", description: "returns whether the dictionary size is zero.", examples: ["{}.zero?", "{ a: 1 }.zero?", "{ a: 1, b: 2 }.zero?"] }, "one?" => { name: "one?", description: "returns whether the dictionary size is one.", examples: [ "Dictionary.from_entries((1..1).to_list.map((x) => { [x, x] })).one?", "Dictionary.from_entries((1..2).to_list.map((x) => { [x, x] })).one?", "{}.one?" ] }, "two?" => { name: "two?", description: "returns whether the dictionary size is two.", examples: [ "Dictionary.from_entries((1..2).to_list.map((x) => { [x, x] })).two?", "Dictionary.from_entries((1..3).to_list.map((x) => { [x, x] })).two?", "{}.two?" ] }, "three?" => { name: "three?", description: "returns whether the dictionary size is three.", examples: [ "Dictionary.from_entries((1..3).to_list.map((x) => { [x, x] })).three?", "Dictionary.from_entries((1..4).to_list.map((x) => { [x, x] })).three?", "{}.three?" ] }, "four?" => { name: "four?", description: "returns whether the dictionary size is four.", examples: [ "Dictionary.from_entries((1..4).to_list.map((x) => { [x, x] })).four?", "Dictionary.from_entries((1..5).to_list.map((x) => { [x, x] })).four?", "{}.four?" ] }, "five?" => { name: "five?", description: "returns whether the dictionary size is five.", examples: [ "Dictionary.from_entries((1..5).to_list.map((x) => { [x, x] })).five?", "Dictionary.from_entries((1..6).to_list.map((x) => { [x, x] })).five?", "{}.five?" ] }, "six?" => { name: "six?", description: "returns whether the dictionary size is six.", examples: [ "Dictionary.from_entries((1..6).to_list.map((x) => { [x, x] })).six?", "Dictionary.from_entries((1..7).to_list.map((x) => { [x, x] })).six?", "{}.six?" ] }, "seven?" => { name: "seven?", description: "returns whether the dictionary size is seven.", examples: [ "Dictionary.from_entries((1..7).to_list.map((x) => { [x, x] })).seven?", "Dictionary.from_entries((1..8).to_list.map((x) => { [x, x] })).seven?", "{}.seven?" ] }, "eight?" => { name: "eight?", description: "returns whether the dictionary size is eight.", examples: [ "Dictionary.from_entries((1..8).to_list.map((x) => { [x, x] })).eight?", "Dictionary.from_entries((1..9).to_list.map((x) => { [x, x] })).eight?", "{}.eight?" ] }, "nine?" => { name: "nine?", description: "returns whether the dictionary size is nine.", examples: [ "Dictionary.from_entries((1..9).to_list.map((x) => { [x, x] })).nine?", "Dictionary.from_entries((1..10).to_list.map((x) => { [x, x] })).nine?", "{}.nine?" ] }, "ten?" => { name: "ten?", description: "returns whether the dictionary size is ten.", examples: [ "Dictionary.from_entries((1..10).to_list.map((x) => { [x, x] })).ten?", "Dictionary.from_entries((1..11).to_list.map((x) => { [x, x] })).ten?", "{}.ten?" ] }, "eleven?" => { name: "eleven?", description: "returns whether the dictionary size is eleven.", examples: [ "Dictionary.from_entries((1..11).to_list.map((x) => { [x, x] })).eleven?", "Dictionary.from_entries((1..12).to_list.map((x) => { [x, x] })).eleven?", "{}.eleven?" ] }, "twelve?" => { name: "twelve?", description: "returns whether the dictionary size is twelve.", examples: [ "Dictionary.from_entries((1..12).to_list.map((x) => { [x, x] })).twelve?", "Dictionary.from_entries((1..13).to_list.map((x) => { [x, x] })).twelve?", "{}.twelve?" ] }, "thirteen?" => { name: "thirteen?", description: "returns whether the dictionary size is thirteen.", examples: [ "Dictionary.from_entries((1..13).to_list.map((x) => { [x, x] })).thirteen?", "Dictionary.from_entries((1..14).to_list.map((x) => { [x, x] })).thirteen?", "{}.thirteen?" ] }, "fourteen?" => { name: "fourteen?", description: "returns whether the dictionary size is fourteen.", examples: [ "Dictionary.from_entries((1..14).to_list.map((x) => { [x, x] })).fourteen?", "Dictionary.from_entries((1..15).to_list.map((x) => { [x, x] })).fourteen?", "{}.fourteen?" ] }, "fifteen?" => { name: "fifteen?", description: "returns whether the dictionary size is fifteen.", examples: [ "Dictionary.from_entries((1..15).to_list.map((x) => { [x, x] })).fifteen?", "Dictionary.from_entries((1..16).to_list.map((x) => { [x, x] })).fifteen?", "{}.fifteen?" ] }, "sixteen?" => { name: "sixteen?", description: "returns whether the dictionary size is sixteen.", examples: [ "Dictionary.from_entries((1..16).to_list.map((x) => { [x, x] })).sixteen?", "Dictionary.from_entries((1..17).to_list.map((x) => { [x, x] })).sixteen?", "{}.sixteen?" ] }, "seventeen?" => { name: "seventeen?", description: "returns whether the dictionary size is seventeen.", examples: [ "Dictionary.from_entries((1..17).to_list.map((x) => { [x, x] })).seventeen?", "Dictionary.from_entries((1..18).to_list.map((x) => { [x, x] })).seventeen?", "{}.seventeen?" ] }, "eighteen?" => { name: "eighteen?", description: "returns whether the dictionary size is eighteen.", examples: [ "Dictionary.from_entries((1..18).to_list.map((x) => { [x, x] })).eighteen?", "Dictionary.from_entries((1..19).to_list.map((x) => { [x, x] })).eighteen?", "{}.eighteen?" ] }, "nineteen?" => { name: "nineteen?", description: "returns whether the dictionary size is nineteen.", examples: [ "Dictionary.from_entries((1..19).to_list.map((x) => { [x, x] })).nineteen?", "Dictionary.from_entries((1..20).to_list.map((x) => { [x, x] })).nineteen?", "{}.nineteen?" ] }, "twenty?" => { name: "twenty?", description: "returns whether the dictionary size is twenty.", examples: [ "Dictionary.from_entries((1..20).to_list.map((x) => { [x, x] })).twenty?", "Dictionary.from_entries((1..21).to_list.map((x) => { [x, x] })).twenty?", "{}.twenty?" ] }, "twenty_one?" => { name: "twenty_one?", description: "returns whether the dictionary size is twenty one.", examples: [ "Dictionary.from_entries((1..21).to_list.map((x) => { [x, x] })).twenty_one?", "Dictionary.from_entries((1..22).to_list.map((x) => { [x, x] })).twenty_one?", "{}.twenty_one?" ] }, "twenty_two?" => { name: "twenty_two?", description: "returns whether the dictionary size is twenty two.", examples: [ "Dictionary.from_entries((1..22).to_list.map((x) => { [x, x] })).twenty_two?", "Dictionary.from_entries((1..23).to_list.map((x) => { [x, x] })).twenty_two?", "{}.twenty_two?" ] }, "twenty_three?" => { name: "twenty_three?", description: "returns whether the dictionary size is twenty three.", examples: [ "Dictionary.from_entries((1..23).to_list.map((x) => { [x, x] })).twenty_three?", "Dictionary.from_entries((1..24).to_list.map((x) => { [x, x] })).twenty_three?", "{}.twenty_three?" ] }, "twenty_four?" => { name: "twenty_four?", description: "returns whether the dictionary size is twenty four.", examples: [ "Dictionary.from_entries((1..24).to_list.map((x) => { [x, x] })).twenty_four?", "Dictionary.from_entries((1..25).to_list.map((x) => { [x, x] })).twenty_four?", "{}.twenty_four?" ] }, "twenty_five?" => { name: "twenty_five?", description: "returns whether the dictionary size is twenty five.", examples: [ "Dictionary.from_entries((1..25).to_list.map((x) => { [x, x] })).twenty_five?", "Dictionary.from_entries((1..26).to_list.map((x) => { [x, x] })).twenty_five?", "{}.twenty_five?" ] }, "twenty_six?" => { name: "twenty_six?", description: "returns whether the dictionary size is twenty six.", examples: [ "Dictionary.from_entries((1..26).to_list.map((x) => { [x, x] })).twenty_six?", "Dictionary.from_entries((1..27).to_list.map((x) => { [x, x] })).twenty_six?", "{}.twenty_six?" ] }, "twenty_seven?" => { name: "twenty_seven?", description: "returns whether the dictionary size is twenty seven.", examples: [ "Dictionary.from_entries((1..27).to_list.map((x) => { [x, x] })).twenty_seven?", "Dictionary.from_entries((1..28).to_list.map((x) => { [x, x] })).twenty_seven?", "{}.twenty_seven?" ] }, "twenty_eight?" => { name: "twenty_eight?", description: "returns whether the dictionary size is twenty eight.", examples: [ "Dictionary.from_entries((1..28).to_list.map((x) => { [x, x] })).twenty_eight?", "Dictionary.from_entries((1..29).to_list.map((x) => { [x, x] })).twenty_eight?", "{}.twenty_eight?" ] }, "twenty_nine?" => { name: "twenty_nine?", description: "returns whether the dictionary size is twenty nine.", examples: [ "Dictionary.from_entries((1..29).to_list.map((x) => { [x, x] })).twenty_nine?", "Dictionary.from_entries((1..30).to_list.map((x) => { [x, x] })).twenty_nine?", "{}.twenty_nine?" ] }, "thirty?" => { name: "thirty?", description: "returns whether the dictionary size is thirty.", examples: [ "Dictionary.from_entries((1..30).to_list.map((x) => { [x, x] })).thirty?", "Dictionary.from_entries((1..31).to_list.map((x) => { [x, x] })).thirty?", "{}.thirty?" ] }, "thirty_one?" => { name: "thirty_one?", description: "returns whether the dictionary size is thirty one.", examples: [ "Dictionary.from_entries((1..31).to_list.map((x) => { [x, x] })).thirty_one?", "Dictionary.from_entries((1..32).to_list.map((x) => { [x, x] })).thirty_one?", "{}.thirty_one?" ] }, "thirty_two?" => { name: "thirty_two?", description: "returns whether the dictionary size is thirty two.", examples: [ "Dictionary.from_entries((1..32).to_list.map((x) => { [x, x] })).thirty_two?", "Dictionary.from_entries((1..33).to_list.map((x) => { [x, x] })).thirty_two?", "{}.thirty_two?" ] }, "thirty_three?" => { name: "thirty_three?", description: "returns whether the dictionary size is thirty three.", examples: [ "Dictionary.from_entries((1..33).to_list.map((x) => { [x, x] })).thirty_three?", "Dictionary.from_entries((1..34).to_list.map((x) => { [x, x] })).thirty_three?", "{}.thirty_three?" ] }, "thirty_four?" => { name: "thirty_four?", description: "returns whether the dictionary size is thirty four.", examples: [ "Dictionary.from_entries((1..34).to_list.map((x) => { [x, x] })).thirty_four?", "Dictionary.from_entries((1..35).to_list.map((x) => { [x, x] })).thirty_four?", "{}.thirty_four?" ] }, "thirty_five?" => { name: "thirty_five?", description: "returns whether the dictionary size is thirty five.", examples: [ "Dictionary.from_entries((1..35).to_list.map((x) => { [x, x] })).thirty_five?", "Dictionary.from_entries((1..36).to_list.map((x) => { [x, x] })).thirty_five?", "{}.thirty_five?" ] }, "thirty_six?" => { name: "thirty_six?", description: "returns whether the dictionary size is thirty six.", examples: [ "Dictionary.from_entries((1..36).to_list.map((x) => { [x, x] })).thirty_six?", "Dictionary.from_entries((1..37).to_list.map((x) => { [x, x] })).thirty_six?", "{}.thirty_six?" ] }, "thirty_seven?" => { name: "thirty_seven?", description: "returns whether the dictionary size is thirty seven.", examples: [ "Dictionary.from_entries((1..37).to_list.map((x) => { [x, x] })).thirty_seven?", "Dictionary.from_entries((1..38).to_list.map((x) => { [x, x] })).thirty_seven?", "{}.thirty_seven?" ] }, "thirty_eight?" => { name: "thirty_eight?", description: "returns whether the dictionary size is thirty eight.", examples: [ "Dictionary.from_entries((1..38).to_list.map((x) => { [x, x] })).thirty_eight?", "Dictionary.from_entries((1..39).to_list.map((x) => { [x, x] })).thirty_eight?", "{}.thirty_eight?" ] }, "thirty_nine?" => { name: "thirty_nine?", description: "returns whether the dictionary size is thirty nine.", examples: [ "Dictionary.from_entries((1..39).to_list.map((x) => { [x, x] })).thirty_nine?", "Dictionary.from_entries((1..40).to_list.map((x) => { [x, x] })).thirty_nine?", "{}.thirty_nine?" ] }, "forty?" => { name: "forty?", description: "returns whether the dictionary size is forty.", examples: [ "Dictionary.from_entries((1..40).to_list.map((x) => { [x, x] })).forty?", "Dictionary.from_entries((1..41).to_list.map((x) => { [x, x] })).forty?", "{}.forty?" ] }, "forty_one?" => { name: "forty_one?", description: "returns whether the dictionary size is forty one.", examples: [ "Dictionary.from_entries((1..41).to_list.map((x) => { [x, x] })).forty_one?", "Dictionary.from_entries((1..42).to_list.map((x) => { [x, x] })).forty_one?", "{}.forty_one?" ] }, "forty_two?" => { name: "forty_two?", description: "returns whether the dictionary size is forty two.", examples: [ "Dictionary.from_entries((1..42).to_list.map((x) => { [x, x] })).forty_two?", "Dictionary.from_entries((1..43).to_list.map((x) => { [x, x] })).forty_two?", "{}.forty_two?" ] }, "forty_three?" => { name: "forty_three?", description: "returns whether the dictionary size is forty three.", examples: [ "Dictionary.from_entries((1..43).to_list.map((x) => { [x, x] })).forty_three?", "Dictionary.from_entries((1..44).to_list.map((x) => { [x, x] })).forty_three?", "{}.forty_three?" ] }, "forty_four?" => { name: "forty_four?", description: "returns whether the dictionary size is forty four.", examples: [ "Dictionary.from_entries((1..44).to_list.map((x) => { [x, x] })).forty_four?", "Dictionary.from_entries((1..45).to_list.map((x) => { [x, x] })).forty_four?", "{}.forty_four?" ] }, "forty_five?" => { name: "forty_five?", description: "returns whether the dictionary size is forty five.", examples: [ "Dictionary.from_entries((1..45).to_list.map((x) => { [x, x] })).forty_five?", "Dictionary.from_entries((1..46).to_list.map((x) => { [x, x] })).forty_five?", "{}.forty_five?" ] }, "forty_six?" => { name: "forty_six?", description: "returns whether the dictionary size is forty six.", examples: [ "Dictionary.from_entries((1..46).to_list.map((x) => { [x, x] })).forty_six?", "Dictionary.from_entries((1..47).to_list.map((x) => { [x, x] })).forty_six?", "{}.forty_six?" ] }, "forty_seven?" => { name: "forty_seven?", description: "returns whether the dictionary size is forty seven.", examples: [ "Dictionary.from_entries((1..47).to_list.map((x) => { [x, x] })).forty_seven?", "Dictionary.from_entries((1..48).to_list.map((x) => { [x, x] })).forty_seven?", "{}.forty_seven?" ] }, "forty_eight?" => { name: "forty_eight?", description: "returns whether the dictionary size is forty eight.", examples: [ "Dictionary.from_entries((1..48).to_list.map((x) => { [x, x] })).forty_eight?", "Dictionary.from_entries((1..49).to_list.map((x) => { [x, x] })).forty_eight?", "{}.forty_eight?" ] }, "forty_nine?" => { name: "forty_nine?", description: "returns whether the dictionary size is forty nine.", examples: [ "Dictionary.from_entries((1..49).to_list.map((x) => { [x, x] })).forty_nine?", "Dictionary.from_entries((1..50).to_list.map((x) => { [x, x] })).forty_nine?", "{}.forty_nine?" ] }, "fifty?" => { name: "fifty?", description: "returns whether the dictionary size is fifty.", examples: [ "Dictionary.from_entries((1..50).to_list.map((x) => { [x, x] })).fifty?", "Dictionary.from_entries((1..51).to_list.map((x) => { [x, x] })).fifty?", "{}.fifty?" ] }, "fifty_one?" => { name: "fifty_one?", description: "returns whether the dictionary size is fifty one.", examples: [ "Dictionary.from_entries((1..51).to_list.map((x) => { [x, x] })).fifty_one?", "Dictionary.from_entries((1..52).to_list.map((x) => { [x, x] })).fifty_one?", "{}.fifty_one?" ] }, "fifty_two?" => { name: "fifty_two?", description: "returns whether the dictionary size is fifty two.", examples: [ "Dictionary.from_entries((1..52).to_list.map((x) => { [x, x] })).fifty_two?", "Dictionary.from_entries((1..53).to_list.map((x) => { [x, x] })).fifty_two?", "{}.fifty_two?" ] }, "fifty_three?" => { name: "fifty_three?", description: "returns whether the dictionary size is fifty three.", examples: [ "Dictionary.from_entries((1..53).to_list.map((x) => { [x, x] })).fifty_three?", "Dictionary.from_entries((1..54).to_list.map((x) => { [x, x] })).fifty_three?", "{}.fifty_three?" ] }, "fifty_four?" => { name: "fifty_four?", description: "returns whether the dictionary size is fifty four.", examples: [ "Dictionary.from_entries((1..54).to_list.map((x) => { [x, x] })).fifty_four?", "Dictionary.from_entries((1..55).to_list.map((x) => { [x, x] })).fifty_four?", "{}.fifty_four?" ] }, "fifty_five?" => { name: "fifty_five?", description: "returns whether the dictionary size is fifty five.", examples: [ "Dictionary.from_entries((1..55).to_list.map((x) => { [x, x] })).fifty_five?", "Dictionary.from_entries((1..56).to_list.map((x) => { [x, x] })).fifty_five?", "{}.fifty_five?" ] }, "fifty_six?" => { name: "fifty_six?", description: "returns whether the dictionary size is fifty six.", examples: [ "Dictionary.from_entries((1..56).to_list.map((x) => { [x, x] })).fifty_six?", "Dictionary.from_entries((1..57).to_list.map((x) => { [x, x] })).fifty_six?", "{}.fifty_six?" ] }, "fifty_seven?" => { name: "fifty_seven?", description: "returns whether the dictionary size is fifty seven.", examples: [ "Dictionary.from_entries((1..57).to_list.map((x) => { [x, x] })).fifty_seven?", "Dictionary.from_entries((1..58).to_list.map((x) => { [x, x] })).fifty_seven?", "{}.fifty_seven?" ] }, "fifty_eight?" => { name: "fifty_eight?", description: "returns whether the dictionary size is fifty eight.", examples: [ "Dictionary.from_entries((1..58).to_list.map((x) => { [x, x] })).fifty_eight?", "Dictionary.from_entries((1..59).to_list.map((x) => { [x, x] })).fifty_eight?", "{}.fifty_eight?" ] }, "fifty_nine?" => { name: "fifty_nine?", description: "returns whether the dictionary size is fifty nine.", examples: [ "Dictionary.from_entries((1..59).to_list.map((x) => { [x, x] })).fifty_nine?", "Dictionary.from_entries((1..60).to_list.map((x) => { [x, x] })).fifty_nine?", "{}.fifty_nine?" ] }, "sixty?" => { name: "sixty?", description: "returns whether the dictionary size is sixty.", examples: [ "Dictionary.from_entries((1..60).to_list.map((x) => { [x, x] })).sixty?", "Dictionary.from_entries((1..61).to_list.map((x) => { [x, x] })).sixty?", "{}.sixty?" ] }, "sixty_one?" => { name: "sixty_one?", description: "returns whether the dictionary size is sixty one.", examples: [ "Dictionary.from_entries((1..61).to_list.map((x) => { [x, x] })).sixty_one?", "Dictionary.from_entries((1..62).to_list.map((x) => { [x, x] })).sixty_one?", "{}.sixty_one?" ] }, "sixty_two?" => { name: "sixty_two?", description: "returns whether the dictionary size is sixty two.", examples: [ "Dictionary.from_entries((1..62).to_list.map((x) => { [x, x] })).sixty_two?", "Dictionary.from_entries((1..63).to_list.map((x) => { [x, x] })).sixty_two?", "{}.sixty_two?" ] }, "sixty_three?" => { name: "sixty_three?", description: "returns whether the dictionary size is sixty three.", examples: [ "Dictionary.from_entries((1..63).to_list.map((x) => { [x, x] })).sixty_three?", "Dictionary.from_entries((1..64).to_list.map((x) => { [x, x] })).sixty_three?", "{}.sixty_three?" ] }, "sixty_four?" => { name: "sixty_four?", description: "returns whether the dictionary size is sixty four.", examples: [ "Dictionary.from_entries((1..64).to_list.map((x) => { [x, x] })).sixty_four?", "Dictionary.from_entries((1..65).to_list.map((x) => { [x, x] })).sixty_four?", "{}.sixty_four?" ] }, "sixty_five?" => { name: "sixty_five?", description: "returns whether the dictionary size is sixty five.", examples: [ "Dictionary.from_entries((1..65).to_list.map((x) => { [x, x] })).sixty_five?", "Dictionary.from_entries((1..66).to_list.map((x) => { [x, x] })).sixty_five?", "{}.sixty_five?" ] }, "sixty_six?" => { name: "sixty_six?", description: "returns whether the dictionary size is sixty six.", examples: [ "Dictionary.from_entries((1..66).to_list.map((x) => { [x, x] })).sixty_six?", "Dictionary.from_entries((1..67).to_list.map((x) => { [x, x] })).sixty_six?", "{}.sixty_six?" ] }, "sixty_seven?" => { name: "sixty_seven?", description: "returns whether the dictionary size is sixty seven.", examples: [ "Dictionary.from_entries((1..67).to_list.map((x) => { [x, x] })).sixty_seven?", "Dictionary.from_entries((1..68).to_list.map((x) => { [x, x] })).sixty_seven?", "{}.sixty_seven?" ] }, "sixty_eight?" => { name: "sixty_eight?", description: "returns whether the dictionary size is sixty eight.", examples: [ "Dictionary.from_entries((1..68).to_list.map((x) => { [x, x] })).sixty_eight?", "Dictionary.from_entries((1..69).to_list.map((x) => { [x, x] })).sixty_eight?", "{}.sixty_eight?" ] }, "sixty_nine?" => { name: "sixty_nine?", description: "returns whether the dictionary size is sixty nine.", examples: [ "Dictionary.from_entries((1..69).to_list.map((x) => { [x, x] })).sixty_nine?", "Dictionary.from_entries((1..70).to_list.map((x) => { [x, x] })).sixty_nine?", "{}.sixty_nine?" ] }, "seventy?" => { name: "seventy?", description: "returns whether the dictionary size is seventy.", examples: [ "Dictionary.from_entries((1..70).to_list.map((x) => { [x, x] })).seventy?", "Dictionary.from_entries((1..71).to_list.map((x) => { [x, x] })).seventy?", "{}.seventy?" ] }, "seventy_one?" => { name: "seventy_one?", description: "returns whether the dictionary size is seventy one.", examples: [ "Dictionary.from_entries((1..71).to_list.map((x) => { [x, x] })).seventy_one?", "Dictionary.from_entries((1..72).to_list.map((x) => { [x, x] })).seventy_one?", "{}.seventy_one?" ] }, "seventy_two?" => { name: "seventy_two?", description: "returns whether the dictionary size is seventy two.", examples: [ "Dictionary.from_entries((1..72).to_list.map((x) => { [x, x] })).seventy_two?", "Dictionary.from_entries((1..73).to_list.map((x) => { [x, x] })).seventy_two?", "{}.seventy_two?" ] }, "seventy_three?" => { name: "seventy_three?", description: "returns whether the dictionary size is seventy three.", examples: [ "Dictionary.from_entries((1..73).to_list.map((x) => { [x, x] })).seventy_three?", "Dictionary.from_entries((1..74).to_list.map((x) => { [x, x] })).seventy_three?", "{}.seventy_three?" ] }, "seventy_four?" => { name: "seventy_four?", description: "returns whether the dictionary size is seventy four.", examples: [ "Dictionary.from_entries((1..74).to_list.map((x) => { [x, x] })).seventy_four?", "Dictionary.from_entries((1..75).to_list.map((x) => { [x, x] })).seventy_four?", "{}.seventy_four?" ] }, "seventy_five?" => { name: "seventy_five?", description: "returns whether the dictionary size is seventy five.", examples: [ "Dictionary.from_entries((1..75).to_list.map((x) => { [x, x] })).seventy_five?", "Dictionary.from_entries((1..76).to_list.map((x) => { [x, x] })).seventy_five?", "{}.seventy_five?" ] }, "seventy_six?" => { name: "seventy_six?", description: "returns whether the dictionary size is seventy six.", examples: [ "Dictionary.from_entries((1..76).to_list.map((x) => { [x, x] })).seventy_six?", "Dictionary.from_entries((1..77).to_list.map((x) => { [x, x] })).seventy_six?", "{}.seventy_six?" ] }, "seventy_seven?" => { name: "seventy_seven?", description: "returns whether the dictionary size is seventy seven.", examples: [ "Dictionary.from_entries((1..77).to_list.map((x) => { [x, x] })).seventy_seven?", "Dictionary.from_entries((1..78).to_list.map((x) => { [x, x] })).seventy_seven?", "{}.seventy_seven?" ] }, "seventy_eight?" => { name: "seventy_eight?", description: "returns whether the dictionary size is seventy eight.", examples: [ "Dictionary.from_entries((1..78).to_list.map((x) => { [x, x] })).seventy_eight?", "Dictionary.from_entries((1..79).to_list.map((x) => { [x, x] })).seventy_eight?", "{}.seventy_eight?" ] }, "seventy_nine?" => { name: "seventy_nine?", description: "returns whether the dictionary size is seventy nine.", examples: [ "Dictionary.from_entries((1..79).to_list.map((x) => { [x, x] })).seventy_nine?", "Dictionary.from_entries((1..80).to_list.map((x) => { [x, x] })).seventy_nine?", "{}.seventy_nine?" ] }, "eighty?" => { name: "eighty?", description: "returns whether the dictionary size is eighty.", examples: [ "Dictionary.from_entries((1..80).to_list.map((x) => { [x, x] })).eighty?", "Dictionary.from_entries((1..81).to_list.map((x) => { [x, x] })).eighty?", "{}.eighty?" ] }, "eighty_one?" => { name: "eighty_one?", description: "returns whether the dictionary size is eighty one.", examples: [ "Dictionary.from_entries((1..81).to_list.map((x) => { [x, x] })).eighty_one?", "Dictionary.from_entries((1..82).to_list.map((x) => { [x, x] })).eighty_one?", "{}.eighty_one?" ] }, "eighty_two?" => { name: "eighty_two?", description: "returns whether the dictionary size is eighty two.", examples: [ "Dictionary.from_entries((1..82).to_list.map((x) => { [x, x] })).eighty_two?", "Dictionary.from_entries((1..83).to_list.map((x) => { [x, x] })).eighty_two?", "{}.eighty_two?" ] }, "eighty_three?" => { name: "eighty_three?", description: "returns whether the dictionary size is eighty three.", examples: [ "Dictionary.from_entries((1..83).to_list.map((x) => { [x, x] })).eighty_three?", "Dictionary.from_entries((1..84).to_list.map((x) => { [x, x] })).eighty_three?", "{}.eighty_three?" ] }, "eighty_four?" => { name: "eighty_four?", description: "returns whether the dictionary size is eighty four.", examples: [ "Dictionary.from_entries((1..84).to_list.map((x) => { [x, x] })).eighty_four?", "Dictionary.from_entries((1..85).to_list.map((x) => { [x, x] })).eighty_four?", "{}.eighty_four?" ] }, "eighty_five?" => { name: "eighty_five?", description: "returns whether the dictionary size is eighty five.", examples: [ "Dictionary.from_entries((1..85).to_list.map((x) => { [x, x] })).eighty_five?", "Dictionary.from_entries((1..86).to_list.map((x) => { [x, x] })).eighty_five?", "{}.eighty_five?" ] }, "eighty_six?" => { name: "eighty_six?", description: "returns whether the dictionary size is eighty six.", examples: [ "Dictionary.from_entries((1..86).to_list.map((x) => { [x, x] })).eighty_six?", "Dictionary.from_entries((1..87).to_list.map((x) => { [x, x] })).eighty_six?", "{}.eighty_six?" ] }, "eighty_seven?" => { name: "eighty_seven?", description: "returns whether the dictionary size is eighty seven.", examples: [ "Dictionary.from_entries((1..87).to_list.map((x) => { [x, x] })).eighty_seven?", "Dictionary.from_entries((1..88).to_list.map((x) => { [x, x] })).eighty_seven?", "{}.eighty_seven?" ] }, "eighty_eight?" => { name: "eighty_eight?", description: "returns whether the dictionary size is eighty eight.", examples: [ "Dictionary.from_entries((1..88).to_list.map((x) => { [x, x] })).eighty_eight?", "Dictionary.from_entries((1..89).to_list.map((x) => { [x, x] })).eighty_eight?", "{}.eighty_eight?" ] }, "eighty_nine?" => { name: "eighty_nine?", description: "returns whether the dictionary size is eighty nine.", examples: [ "Dictionary.from_entries((1..89).to_list.map((x) => { [x, x] })).eighty_nine?", "Dictionary.from_entries((1..90).to_list.map((x) => { [x, x] })).eighty_nine?", "{}.eighty_nine?" ] }, "ninety?" => { name: "ninety?", description: "returns whether the dictionary size is ninety.", examples: [ "Dictionary.from_entries((1..90).to_list.map((x) => { [x, x] })).ninety?", "Dictionary.from_entries((1..91).to_list.map((x) => { [x, x] })).ninety?", "{}.ninety?" ] }, "ninety_one?" => { name: "ninety_one?", description: "returns whether the dictionary size is ninety one.", examples: [ "Dictionary.from_entries((1..91).to_list.map((x) => { [x, x] })).ninety_one?", "Dictionary.from_entries((1..92).to_list.map((x) => { [x, x] })).ninety_one?", "{}.ninety_one?" ] }, "ninety_two?" => { name: "ninety_two?", description: "returns whether the dictionary size is ninety two.", examples: [ "Dictionary.from_entries((1..92).to_list.map((x) => { [x, x] })).ninety_two?", "Dictionary.from_entries((1..93).to_list.map((x) => { [x, x] })).ninety_two?", "{}.ninety_two?" ] }, "ninety_three?" => { name: "ninety_three?", description: "returns whether the dictionary size is ninety three.", examples: [ "Dictionary.from_entries((1..93).to_list.map((x) => { [x, x] })).ninety_three?", "Dictionary.from_entries((1..94).to_list.map((x) => { [x, x] })).ninety_three?", "{}.ninety_three?" ] }, "ninety_four?" => { name: "ninety_four?", description: "returns whether the dictionary size is ninety four.", examples: [ "Dictionary.from_entries((1..94).to_list.map((x) => { [x, x] })).ninety_four?", "Dictionary.from_entries((1..95).to_list.map((x) => { [x, x] })).ninety_four?", "{}.ninety_four?" ] }, "ninety_five?" => { name: "ninety_five?", description: "returns whether the dictionary size is ninety five.", examples: [ "Dictionary.from_entries((1..95).to_list.map((x) => { [x, x] })).ninety_five?", "Dictionary.from_entries((1..96).to_list.map((x) => { [x, x] })).ninety_five?", "{}.ninety_five?" ] }, "ninety_six?" => { name: "ninety_six?", description: "returns whether the dictionary size is ninety six.", examples: [ "Dictionary.from_entries((1..96).to_list.map((x) => { [x, x] })).ninety_six?", "Dictionary.from_entries((1..97).to_list.map((x) => { [x, x] })).ninety_six?", "{}.ninety_six?" ] }, "ninety_seven?" => { name: "ninety_seven?", description: "returns whether the dictionary size is ninety seven.", examples: [ "Dictionary.from_entries((1..97).to_list.map((x) => { [x, x] })).ninety_seven?", "Dictionary.from_entries((1..98).to_list.map((x) => { [x, x] })).ninety_seven?", "{}.ninety_seven?" ] }, "ninety_eight?" => { name: "ninety_eight?", description: "returns whether the dictionary size is ninety eight.", examples: [ "Dictionary.from_entries((1..98).to_list.map((x) => { [x, x] })).ninety_eight?", "Dictionary.from_entries((1..99).to_list.map((x) => { [x, x] })).ninety_eight?", "{}.ninety_eight?" ] }, "ninety_nine?" => { name: "ninety_nine?", description: "returns whether the dictionary size is ninety nine.", examples: [ "Dictionary.from_entries((1..99).to_list.map((x) => { [x, x] })).ninety_nine?", "Dictionary.from_entries((1..100).to_list.map((x) => { [x, x] })).ninety_nine?", "{}.ninety_nine?" ] }, "one_hundred?" => { name: "one_hundred?", description: "returns whether the dictionary size is one hundred.", examples: [ "Dictionary.from_entries((1..100).to_list.map((x) => { [x, x] })).one_hundred?", "Dictionary.from_entries((1..101).to_list.map((x) => { [x, x] })).one_hundred?", "{}.one_hundred?" ] } }.freeze
Constants inherited from Code::Object
Constants included from Concerns::Shared
Concerns::Shared::COMPOUND_ASSIGNMENT_OPERATORS, Concerns::Shared::OPERATOR_METHOD_ALIASES, Concerns::Shared::SHARED_OPERATORS
Instance Attribute Summary
Attributes included from Concerns::Shared
Class Method Summary collapse
- .call(**args) ⇒ Object
- .code_assign(*dictionaries) ⇒ Object
- .code_entries(dictionary) ⇒ Object
- .code_from_entries(entries) ⇒ Object
- .code_has_own?(dictionary, key) ⇒ Boolean
- .function_documentation(scope) ⇒ Object
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #call(**args) ⇒ Object
- #code_any?(argument, **globals) ⇒ Boolean
- #code_associate(key) ⇒ Object
- #code_clear ⇒ Object
- #code_compact(argument = nil, **globals) ⇒ Object
- #code_compact!(argument = nil, **globals) ⇒ Object
- #code_deep_duplicate(seen = {}) ⇒ Object
- #code_delete(*arguments, index: 0, **globals) ⇒ Object
- #code_delete_if(argument, **globals) ⇒ Object
- #code_delete_unless(argument, **globals) ⇒ Object
- #code_dig(*arguments) ⇒ Object
- #code_each(argument, **globals) ⇒ Object
- #code_each_key(argument, **globals) ⇒ Object
- #code_each_pair(argument, **globals) ⇒ Object
- #code_each_value(argument, **globals) ⇒ Object
- #code_empty? ⇒ Boolean
- #code_except(*arguments) ⇒ Object
- #code_fetch(*arguments, index: 0, **globals) ⇒ Object
- #code_fetch_values(*arguments) ⇒ Object
- #code_flatten(level = nil) ⇒ Object
- #code_get(key) ⇒ Object
- #code_has_key?(key) ⇒ Boolean
- #code_has_own?(key) ⇒ Boolean
- #code_has_value?(key) ⇒ Boolean
- #code_invert ⇒ Object
- #code_keep_if(argument, **globals) ⇒ Object
- #code_keep_unless(argument, **globals) ⇒ Object
- #code_key(value, function = nil, **globals) ⇒ Object
- #code_keys ⇒ Object
- #code_map(function, **globals) ⇒ Object
- #code_merge(*arguments, **globals) ⇒ Object
- #code_merge!(*arguments, **globals) ⇒ Object
- #code_reject(argument, **globals) ⇒ Object
- #code_reject!(argument, **globals) ⇒ Object
- #code_replace(dictionary) ⇒ Object
- #code_right_associate(value) ⇒ Object
- #code_select(argument, **globals) ⇒ Object
- #code_select!(argument, **globals) ⇒ Object
- #code_set(key, value) ⇒ Object
- #code_shift ⇒ Object
- #code_size ⇒ Object
- #code_slice(*arguments) ⇒ Object
- #code_store(key, value) ⇒ Object
- #code_to_context ⇒ Object
- #code_to_dictionary ⇒ Object
- #code_to_list ⇒ Object
- #code_to_query(namespace = nil) ⇒ Object
- #code_transform_keys(function, **globals) ⇒ Object
- #code_transform_keys!(function, **globals) ⇒ Object
- #code_transform_values(function, **globals) ⇒ Object
- #code_transform_values!(function, **globals) ⇒ Object
- #code_update(*arguments, **globals) ⇒ Object
- #code_values(*arguments, **globals) ⇒ Object
- #code_values_at(*keys) ⇒ Object
-
#initialize(*args, **kargs, &_block) ⇒ Dictionary
constructor
A new instance of Dictionary.
- #present? ⇒ Boolean
Methods inherited from Code::Object
class_documentation, class_functions, code_new, #code_new, documentation, documentation_for, documented_functions_for, function_documentation_for, function_documentation_registry_for, functions, inherited_function_documentation_for, instance_functions, maybe, #name, repeat, sorted_dictionary, |
Methods included from Concerns::Shared
#==, #as_json, #blank?, #code_and, #code_as_json, #code_blank?, #code_class_functions, #code_compare, #code_different, #code_documentable_functions, #code_documentation, #code_duplicate, #code_dynamic_call, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_false?, #code_falsy?, code_fetch, #code_functions, code_get, #code_greater, #code_greater_or_equal, #code_inclusive_range, #code_inspect, #code_instance_functions, #code_instance_of?, #code_is_a?, #code_itself, #code_less, #code_less_or_equal, #code_name, #code_nothing?, #code_or, #code_presence, #code_presence_in, #code_present?, #code_respond_to?, #code_same_object?, #code_self, #code_send, code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_tap, #code_then, #code_to_boolean, #code_to_class, #code_to_date, #code_to_decimal, #code_to_duration, #code_to_integer, #code_to_json, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_string, #code_to_time, #code_true?, #code_truthy?, #eql?, #falsy?, #hash, #inspect, #multi_fetch, #nothing?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #truthy?
Constructor Details
#initialize(*args, **kargs, &_block) ⇒ Dictionary
Returns a new instance of Dictionary.
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 |
# File 'lib/code/object/dictionary.rb', line 1637 def initialize(*args, **kargs, &_block) self.raw = args .map do |arg| if arg.is_an?(::Hash) arg.transform_keys(&:to_code).transform_values(&:to_code) elsif arg.is_a?(Dictionary) arg.raw.transform_keys(&:to_code).transform_values(&:to_code) elsif arg.is_a?(Node::FunctionParameter) arg.to_h.transform_keys(&:to_code).transform_values(&:to_code) else {} end end .reduce({}, &:merge) .merge(kargs.transform_keys(&:to_code).transform_values(&:to_code)) end |
Class Method Details
.call(**args) ⇒ Object
1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 |
# File 'lib/code/object/dictionary.rb', line 1655 def self.call(**args) code_operator = args.fetch(:operator, nil).to_code code_arguments = args.fetch(:arguments, List.new).to_code code_value = code_arguments.code_first case code_operator.to_s when "entries" sig(args) { Dictionary } code_entries(code_value) when "from_entries" sig(args) { List } code_from_entries(code_value) when "assign" sig(args) { Dictionary.repeat(1) } code_assign(*code_arguments.raw) when "has_own?" sig(args) { [Dictionary, Object] } code_has_own?(*code_arguments.raw) else super end end |
.code_assign(*dictionaries) ⇒ Object
2210 2211 2212 2213 2214 2215 2216 2217 |
# File 'lib/code/object/dictionary.rb', line 2210 def self.code_assign(*dictionaries) Dictionary.new( dictionaries .to_code .raw .reduce({}) { |acc, item| acc.merge(item.raw) } ) end |
.code_entries(dictionary) ⇒ Object
2202 2203 2204 |
# File 'lib/code/object/dictionary.rb', line 2202 def self.code_entries(dictionary) dictionary.to_code.code_to_list end |
.code_from_entries(entries) ⇒ Object
2206 2207 2208 |
# File 'lib/code/object/dictionary.rb', line 2206 def self.code_from_entries(entries) entries.to_code.code_to_dictionary end |
.code_has_own?(dictionary, key) ⇒ Boolean
2219 2220 2221 |
# File 'lib/code/object/dictionary.rb', line 2219 def self.code_has_own?(dictionary, key) dictionary.to_code.code_has_key?(key) end |
.function_documentation(scope) ⇒ Object
1522 1523 1524 1525 1526 1527 |
# File 'lib/code/object/dictionary.rb', line 1522 def self.function_documentation(scope) return INSTANCE_FUNCTIONS if scope == :instance return CLASS_FUNCTIONS if scope == :class {} end |
Instance Method Details
#<=>(other) ⇒ Object
2954 2955 2956 2957 2958 2959 2960 2961 2962 |
# File 'lib/code/object/dictionary.rb', line 2954 def <=>(other) code_other = other.to_code return -1 if self.class != code_other.class return 0 if raw == code_other.raw return -1 if raw < code_other.raw return 1 if raw > code_other.raw -1 end |
#call(**args) ⇒ Object
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 |
# File 'lib/code/object/dictionary.rb', line 1678 def call(**args) code_operator = args.fetch(:operator, nil).to_code code_arguments = args.fetch(:arguments, List.new).to_code globals = multi_fetch(args, *GLOBALS) code_value = code_arguments.code_first stored_value = code_fetch(code_operator) if stored_value.is_a?(Function) return stored_value.call(**args, operator: nil, bound_self: self) end case code_operator.to_s when "[]", "at", "get" sig(args) { Object } code_get(code_value) when "any?" sig(args) { (Function | Class).maybe } code_any?(code_value, **globals) when "clear" sig(args) code_clear when "compact!" sig(args) { (Function | Class).maybe } code_compact!(code_value, **globals) when "compact" sig(args) { (Function | Class).maybe } code_compact(code_value, **globals) when "delete" sig(args) { Object.repeat(1) } code_delete(*code_arguments.raw, **globals) when "delete_if" sig(args) { Function | Class } code_delete_if(code_value, **globals) when "delete_unless" sig(args) { Function | Class } code_delete_unless(code_value, **globals) when "dig" sig(args) { Object.repeat(1) } code_dig(*code_arguments.raw) when "each" sig(args) { Function } code_each(code_value, **globals) when "each_key" sig(args) { Function } code_each_key(code_value, **globals) when "each_value" sig(args) { Function } code_each_value(code_value, **globals) when "each_pair" sig(args) { Function } code_each_pair(code_value, **globals) when "empty?" sig(args) code_empty? when "except" sig(args) { Object.repeat(1) } code_except(*code_arguments.raw) when "fetch" sig(args) { Object.repeat(1) } code_fetch(*code_arguments.raw, **globals) when "fetch_values" sig(args) { Object.repeat(1) } code_fetch_values(*code_arguments.raw) when "flatten" sig(args) { Integer.maybe } code_flatten(code_value) when "has_key?", "key?", "include?", "member?" sig(args) { Object } code_has_key?(code_value) when "has_own?" sig(args) { Object } code_has_own?(code_value) when "has_value?", "value?" sig(args) { Object } code_has_value?(code_value) when "invert" sig(args) code_invert when "keep_if" sig(args) { Function | Class } code_keep_if(code_value, **globals) when "keep_unless" sig(args) { Function | Class } code_keep_unless(code_value, **globals) when "key" sig(args) { [Object, Function.maybe] } code_key(*code_arguments.raw, **globals) when "keys" sig(args) code_keys when "map" sig(args) { Function } code_map(code_value, **globals) when "merge" sig(args) { [Dictionary.repeat, Function.maybe] } code_merge(*code_arguments.raw, **globals) when "merge!" sig(args) { [Dictionary.repeat, Function.maybe] } code_merge!(*code_arguments.raw, **globals) when "update" sig(args) { [Dictionary.repeat, Function.maybe] } code_update(*code_arguments.raw, **globals) when "replace" sig(args) { Dictionary } code_replace(code_value) when "store", "set" sig(args) { [Object, Object] } code_store(*code_arguments.raw) when "shift" sig(args) code_shift when "reject!" sig(args) { Function | Class } code_reject!(code_value, **globals) when "reject" sig(args) { Function | Class } code_reject(code_value, **globals) when "select!", "filter!" sig(args) { Function | Class } code_select!(code_value, **globals) when "select", "filter" sig(args) { Function | Class } code_select(code_value, **globals) when "size", "length" sig(args) code_size when "slice" sig(args) { Object.repeat(1) } code_slice(*code_arguments.raw) when "transform_keys" sig(args) { Function } code_transform_keys(code_value, **globals) when "transform_keys!" sig(args) { Function } code_transform_keys!(code_value, **globals) when "transform_values" sig(args) { Function } code_transform_values(code_value, **globals) when "transform_values!" sig(args) { Function } code_transform_values!(code_value, **globals) when "to_query" sig(args) { String.maybe } code_to_query(code_value) when "to_list", "entries" sig(args) code_to_list when "to_dictionary" sig(args) code_to_dictionary when "to_context" sig(args) code_to_context when "values" sig(args) { [Object.repeat, Function.maybe] } code_values(*code_arguments.raw, **globals) when "values_at" sig(args) { Object.repeat(1) } code_values_at(*code_arguments.raw) when "associate" sig(args) { Object } code_associate(code_value) when "right_associate" sig(args) { Object } code_right_associate(code_value) when "many?" sig(args) code_many? when "positive?" sig(args) code_positive? when "negative?" sig(args) code_negative? when "zero?" sig(args) code_zero? when "one?" sig(args) code_one? when "two?" sig(args) code_two? when "three?" sig(args) code_three? when "four?" sig(args) code_four? when "five?" sig(args) code_five? when "six?" sig(args) code_six? when "seven?" sig(args) code_seven? when "eight?" sig(args) code_eight? when "nine?" sig(args) code_nine? when "ten?" sig(args) code_ten? when "eleven?" sig(args) code_eleven? when "twelve?" sig(args) code_twelve? when "thirteen?" sig(args) code_thirteen? when "fourteen?" sig(args) code_fourteen? when "fifteen?" sig(args) code_fifteen? when "sixteen?" sig(args) code_sixteen? when "seventeen?" sig(args) code_seventeen? when "eighteen?" sig(args) code_eighteen? when "nineteen?" sig(args) code_nineteen? when "twenty?" sig(args) code_twenty? when "twenty_one?" sig(args) code_twenty_one? when "twenty_two?" sig(args) code_twenty_two? when "twenty_three?" sig(args) code_twenty_three? when "twenty_four?" sig(args) code_twenty_four? when "twenty_five?" sig(args) code_twenty_five? when "twenty_six?" sig(args) code_twenty_six? when "twenty_seven?" sig(args) code_twenty_seven? when "twenty_eight?" sig(args) code_twenty_eight? when "twenty_nine?" sig(args) code_twenty_nine? when "thirty?" sig(args) code_thirty? when "thirty_one?" sig(args) code_thirty_one? when "thirty_two?" sig(args) code_thirty_two? when "thirty_three?" sig(args) code_thirty_three? when "thirty_four?" sig(args) code_thirty_four? when "thirty_five?" sig(args) code_thirty_five? when "thirty_six?" sig(args) code_thirty_six? when "thirty_seven?" sig(args) code_thirty_seven? when "thirty_eight?" sig(args) code_thirty_eight? when "thirty_nine?" sig(args) code_thirty_nine? when "forty?" sig(args) code_forty? when "forty_one?" sig(args) code_forty_one? when "forty_two?" sig(args) code_forty_two? when "forty_three?" sig(args) code_forty_three? when "forty_four?" sig(args) code_forty_four? when "forty_five?" sig(args) code_forty_five? when "forty_six?" sig(args) code_forty_six? when "forty_seven?" sig(args) code_forty_seven? when "forty_eight?" sig(args) code_forty_eight? when "forty_nine?" sig(args) code_forty_nine? when "fifty?" sig(args) code_fifty? when "fifty_one?" sig(args) code_fifty_one? when "fifty_two?" sig(args) code_fifty_two? when "fifty_three?" sig(args) code_fifty_three? when "fifty_four?" sig(args) code_fifty_four? when "fifty_five?" sig(args) code_fifty_five? when "fifty_six?" sig(args) code_fifty_six? when "fifty_seven?" sig(args) code_fifty_seven? when "fifty_eight?" sig(args) code_fifty_eight? when "fifty_nine?" sig(args) code_fifty_nine? when "sixty?" sig(args) code_sixty? when "sixty_one?" sig(args) code_sixty_one? when "sixty_two?" sig(args) code_sixty_two? when "sixty_three?" sig(args) code_sixty_three? when "sixty_four?" sig(args) code_sixty_four? when "sixty_five?" sig(args) code_sixty_five? when "sixty_six?" sig(args) code_sixty_six? when "sixty_seven?" sig(args) code_sixty_seven? when "sixty_eight?" sig(args) code_sixty_eight? when "sixty_nine?" sig(args) code_sixty_nine? when "seventy?" sig(args) code_seventy? when "seventy_one?" sig(args) code_seventy_one? when "seventy_two?" sig(args) code_seventy_two? when "seventy_three?" sig(args) code_seventy_three? when "seventy_four?" sig(args) code_seventy_four? when "seventy_five?" sig(args) code_seventy_five? when "seventy_six?" sig(args) code_seventy_six? when "seventy_seven?" sig(args) code_seventy_seven? when "seventy_eight?" sig(args) code_seventy_eight? when "seventy_nine?" sig(args) code_seventy_nine? when "eighty?" sig(args) code_eighty? when "eighty_one?" sig(args) code_eighty_one? when "eighty_two?" sig(args) code_eighty_two? when "eighty_three?" sig(args) code_eighty_three? when "eighty_four?" sig(args) code_eighty_four? when "eighty_five?" sig(args) code_eighty_five? when "eighty_six?" sig(args) code_eighty_six? when "eighty_seven?" sig(args) code_eighty_seven? when "eighty_eight?" sig(args) code_eighty_eight? when "eighty_nine?" sig(args) code_eighty_nine? when "ninety?" sig(args) code_ninety? when "ninety_one?" sig(args) code_ninety_one? when "ninety_two?" sig(args) code_ninety_two? when "ninety_three?" sig(args) code_ninety_three? when "ninety_four?" sig(args) code_ninety_four? when "ninety_five?" sig(args) code_ninety_five? when "ninety_six?" sig(args) code_ninety_six? when "ninety_seven?" sig(args) code_ninety_seven? when "ninety_eight?" sig(args) code_ninety_eight? when "ninety_nine?" sig(args) code_ninety_nine? when "one_hundred?" sig(args) code_one_hundred? when ->(code_operator) { code_has_key?(code_operator).truthy? } result = code_fetch(code_operator) if result.is_a?(Function) result.call(**args, operator: nil, bound_self: self) else sig(args) result end else super end end |
#code_any?(argument, **globals) ⇒ Boolean
2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 |
# File 'lib/code/object/dictionary.rb', line 2169 def code_any?(argument, **globals) code_argument = argument.to_code if code_argument.nothing? Boolean.new(raw.any?) elsif code_argument.is_a?(Class) Boolean.new(raw.any? { |_, value| value.is_a?(code_argument.raw) }) else index = 0 Boolean.new( raw.any? do |key, value| code_argument .call( arguments: List.new([key, value, Integer.new(index), self]), **globals ) .truthy? .tap { index += 1 } rescue Error::Next => e e.code_value.truthy?.tap { index += 1 } end ) end rescue Error::Break => e e.code_value end |
#code_associate(key) ⇒ Object
2924 2925 2926 2927 2928 |
# File 'lib/code/object/dictionary.rb', line 2924 def code_associate(key) code_key = key.to_code raw.key?(code_key) ? List.new([code_key, raw[code_key]]) : Nothing.new end |
#code_clear ⇒ Object
2197 2198 2199 2200 |
# File 'lib/code/object/dictionary.rb', line 2197 def code_clear self.raw = {} self end |
#code_compact(argument = nil, **globals) ⇒ Object
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 |
# File 'lib/code/object/dictionary.rb', line 2223 def code_compact(argument = nil, **globals) code_argument = argument.to_code Dictionary.new( raw.reject.with_index do |(key, value), index| if code_argument.nothing? value.nothing? elsif code_argument.is_a?(Class) value.is_a?(code_argument.raw) else code_argument.call( arguments: List.new([value, key, Integer.new(index), self]), **globals ).truthy? end rescue Error::Next => e e.code_value.truthy? end ) rescue Error::Break => e e.code_value end |
#code_compact!(argument = nil, **globals) ⇒ Object
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 |
# File 'lib/code/object/dictionary.rb', line 2246 def code_compact!(argument = nil, **globals) code_argument = argument.to_code raw.reject!.with_index do |(key, value), index| if code_argument.nothing? value.nothing? elsif code_argument.is_a?(Class) value.is_a?(code_argument.raw) else code_argument.call( arguments: List.new([value, key, Integer.new(index), self]), **globals ).truthy? end rescue Error::Next => e e.code_value.truthy? end self rescue Error::Break => e e.code_value end |
#code_deep_duplicate(seen = {}) ⇒ Object
2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 |
# File 'lib/code/object/dictionary.rb', line 2937 def code_deep_duplicate(seen = {}) seen.compare_by_identity unless seen.compare_by_identity? return seen[self] if seen.key?(self) duplicate = Dictionary.new seen[self] = duplicate raw.each do |key, value| duplicate.code_set( key.code_deep_duplicate(seen), value.code_deep_duplicate(seen) ) end duplicate end |
#code_delete(*arguments, index: 0, **globals) ⇒ Object
2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 |
# File 'lib/code/object/dictionary.rb', line 2269 def code_delete(*arguments, index: 0, **globals) arguments = arguments.to_code.raw code_index = index.to_code code_default = ( arguments.last if arguments.last.is_a?(Function) && arguments.many? ).to_code arguments = arguments[...-1] unless code_default.nothing? code_first = arguments.first.to_code if arguments.one? raw.delete(code_first) do if code_default.nothing? Nothing.new else code_default.call( arguments: List.new([code_first, code_index, self]), **globals ) end rescue Error::Next => e e.code_value end else Dictionary.new( arguments .map .with_index do |code_argument, index| if code_default.nothing? [ code_argument, code_delete(code_argument, index: index, **globals) ] else [ code_argument, code_delete( code_argument, code_default, index: index, **globals ) ] end end .to_h ) end rescue Error::Break => e e.code_value end |
#code_delete_if(argument, **globals) ⇒ Object
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 |
# File 'lib/code/object/dictionary.rb', line 2323 def code_delete_if(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) raw.delete_if { |_, value| value.is_a?(code_argument.raw) } else raw.delete_if.with_index do |(code_key, code_value), index| argument.call( arguments: List.new([code_key, code_value, Integer.new(index), self]), **globals ).truthy? rescue Error::Next => e e.code_value.truthy? end end self rescue Error::Break => e e.code_value end |
#code_delete_unless(argument, **globals) ⇒ Object
2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 |
# File 'lib/code/object/dictionary.rb', line 2345 def code_delete_unless(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) raw.delete_if { |_, value| !value.is_a?(code_argument.raw) } else raw.delete_if.with_index do |(key, value), index| code_argument.call( arguments: List.new([key, value, Integer.new(index), self]), **globals ).falsy? rescue Error::Next => e e.code_value.falsy? end end self rescue Error::Break => e e.code_value end |
#code_dig(*arguments) ⇒ Object
2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 |
# File 'lib/code/object/dictionary.rb', line 2366 def code_dig(*arguments) code_arguments = arguments.to_code code_arguments .raw .reduce(self) do |code_acc, code_element| if code_acc.is_a?(Dictionary) || code_acc.is_a?(List) code_acc.code_get(code_element) else Nothing.new end end end |
#code_each(argument, **globals) ⇒ Object
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 |
# File 'lib/code/object/dictionary.rb', line 2380 def code_each(argument, **globals) code_argument = argument.to_code raw.each.with_index do |(key, value), index| code_argument.call( arguments: List.new([key, value, Integer.new(index), self]), **globals ) rescue Error::Next => e e.code_value end self rescue Error::Break => e e.code_value end |
#code_each_key(argument, **globals) ⇒ Object
2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 |
# File 'lib/code/object/dictionary.rb', line 2397 def code_each_key(argument, **globals) code_argument = argument.to_code raw.each.with_index do |(key, value), index| code_argument.call( arguments: List.new([key, value, Integer.new(index), self]), **globals ) rescue Error::Next => e e.code_value end self rescue Error::Break => e e.code_value end |
#code_each_pair(argument, **globals) ⇒ Object
2418 2419 2420 |
# File 'lib/code/object/dictionary.rb', line 2418 def code_each_pair(argument, **globals) code_each_key(argument, **globals) end |
#code_each_value(argument, **globals) ⇒ Object
2414 2415 2416 |
# File 'lib/code/object/dictionary.rb', line 2414 def code_each_value(argument, **globals) code_each_key(argument, **globals) end |
#code_empty? ⇒ Boolean
2422 2423 2424 |
# File 'lib/code/object/dictionary.rb', line 2422 def code_empty? Boolean.new(raw.empty?) end |
#code_except(*arguments) ⇒ Object
2426 2427 2428 2429 |
# File 'lib/code/object/dictionary.rb', line 2426 def code_except(*arguments) code_arguments = arguments.to_code Dictionary.new(raw.except(*code_arguments.raw)) end |
#code_fetch(*arguments, index: 0, **globals) ⇒ Object
2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 |
# File 'lib/code/object/dictionary.rb', line 2431 def code_fetch(*arguments, index: 0, **globals) code_index = index.to_code arguments = arguments.to_code.raw code_default = ( arguments.last if arguments.last.is_a?(Function) && arguments.many? ).to_code arguments = arguments[..-2] unless code_default.nothing? code_first = arguments.first.to_code if arguments.one? raw.fetch(code_first) do if code_default.nothing? Nothing.new else code_default.call( arguments: List.new([code_first, code_index, self]), **globals ) end rescue Error::Next => e e.code_value end else Dictionary.new( arguments .map .with_index do |code_argument, index| if code_default.nothing? [ code_argument, code_fetch(code_argument, index: index, **globals) ] else [ code_argument, code_fetch( code_argument, code_default, index: index, **globals ) ] end end .to_h ) end rescue Error::Break => e e.code_value end |
#code_fetch_values(*arguments) ⇒ Object
2485 2486 2487 2488 2489 |
# File 'lib/code/object/dictionary.rb', line 2485 def code_fetch_values(*arguments) code_arguments = arguments.to_code List.new(raw.fetch_values(*code_arguments.raw)) end |
#code_flatten(level = nil) ⇒ Object
2491 2492 2493 2494 2495 |
# File 'lib/code/object/dictionary.rb', line 2491 def code_flatten(level = nil) code_level = level.to_code code_level = Integer.new(-1) if code_level.nothing? code_to_list.code_flatten(code_level) end |
#code_get(key) ⇒ Object
2497 2498 2499 2500 |
# File 'lib/code/object/dictionary.rb', line 2497 def code_get(key) code_key = key.to_code raw[code_key] || Nothing.new end |
#code_has_key?(key) ⇒ Boolean
2502 2503 2504 2505 |
# File 'lib/code/object/dictionary.rb', line 2502 def code_has_key?(key) code_key = key.to_code Boolean.new(raw.key?(code_key)) end |
#code_has_own?(key) ⇒ Boolean
2507 2508 2509 |
# File 'lib/code/object/dictionary.rb', line 2507 def code_has_own?(key) code_has_key?(key) end |
#code_has_value?(key) ⇒ Boolean
2511 2512 2513 2514 |
# File 'lib/code/object/dictionary.rb', line 2511 def code_has_value?(key) code_key = key.to_code Boolean.new(raw.value?(code_key)) end |
#code_invert ⇒ Object
2516 2517 2518 |
# File 'lib/code/object/dictionary.rb', line 2516 def code_invert Dictionary.new(raw.invert) end |
#code_keep_if(argument, **globals) ⇒ Object
2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 |
# File 'lib/code/object/dictionary.rb', line 2520 def code_keep_if(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) raw.keep_if { |_, value| value.is_a?(code_argument.raw) } else raw.keep_if.with_index do |(key, value), index| code_argument.call( arguments: List.new([key, value, Integer.new(index), self]), **globals ).truthy? rescue Error::Next => e e.code_value.truthy? end end self rescue Error::Break => e e.code_value end |
#code_keep_unless(argument, **globals) ⇒ Object
2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 |
# File 'lib/code/object/dictionary.rb', line 2541 def code_keep_unless(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) raw.keep_if { |_, value| !value.is_a?(code_argument.raw) } else raw.keep_if.with_index do |(key, value), index| code_argument.call( arguments: List.new([key, value, Integer.new(index), self]), **globals ).falsy? rescue Error::Next => e e.code_value.falsy? end end self rescue Error::Break => e e.code_value end |
#code_key(value, function = nil, **globals) ⇒ Object
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 |
# File 'lib/code/object/dictionary.rb', line 2562 def code_key(value, function = nil, **globals) code_value = value.to_code code_function = function.to_code if code_function.nothing? raw.key(code_value) || Nothing.new else raw.key(code_value) || function.call(arguments: List.new([code_value, self]), **globals) end rescue Error::Next, Error::Break => e e.code_value end |
#code_keys ⇒ Object
2576 2577 2578 |
# File 'lib/code/object/dictionary.rb', line 2576 def code_keys List.new(raw.keys) end |
#code_map(function, **globals) ⇒ Object
2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 |
# File 'lib/code/object/dictionary.rb', line 2580 def code_map(function, **globals) code_function = function.to_code List.new( raw.map.with_index do |(key, value), index| code_function.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ) rescue Error::Next => e e.code_value end ) rescue Error::Break => e e.code_value end |
#code_merge(*arguments, **globals) ⇒ Object
2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 |
# File 'lib/code/object/dictionary.rb', line 2598 def code_merge(*arguments, **globals) arguments = arguments.to_code.raw code_conflict = ( arguments.last if arguments.last.is_a?(Function) && arguments.many? ).to_code arguments = arguments[..-2] unless code_conflict.nothing? index = 0 Dictionary.new( raw.merge(*arguments.map(&:raw)) do |key, old_value, new_value| if code_conflict.nothing? new_value.to_code.tap { index += 1 } else code_conflict .call( arguments: List.new( [ key.to_code, old_value.to_code, new_value.to_code, index.to_code, self ] ), **globals ) .tap { index += 1 } end rescue Error::Next => e e.code_value.tap { index += 1 } end ) rescue Error::Break => e e.code_value end |
#code_merge!(*arguments, **globals) ⇒ Object
2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 |
# File 'lib/code/object/dictionary.rb', line 2639 def code_merge!(*arguments, **globals) arguments = arguments.to_code.raw code_conflict = ( arguments.last if arguments.last.is_a?(Function) && arguments.many? ).to_code arguments = arguments[..-2] unless code_conflict.nothing? index = 0 raw.merge!(*arguments.map(&:raw)) do |key, old_value, new_value| if code_conflict.nothing? new_value.to_code.tap { index += 1 } else code_conflict .call( arguments: List.new( [ key.to_code, old_value.to_code, new_value.to_code, index.to_code, self ] ), **globals ) .tap { index += 1 } end rescue Error::Next => e e.code_value.tap { index += 1 } end self rescue Error::Break => e e.code_value end |
#code_reject(argument, **globals) ⇒ Object
2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 |
# File 'lib/code/object/dictionary.rb', line 2769 def code_reject(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) Dictionary.new( raw.reject { |_, value| value.is_a?(code_argument.raw) } ) else Dictionary.new( raw.reject.with_index do |(key, value), index| code_argument.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ).truthy? rescue Error::Next => e e.code_value.truthy? end ) end rescue Error::Break => e e.code_value end |
#code_reject!(argument, **globals) ⇒ Object
2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 |
# File 'lib/code/object/dictionary.rb', line 2747 def code_reject!(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) raw.reject! { |_, value| value.is_a?(code_argument.raw) } else raw.reject!.with_index do |(key, value), index| code_argument.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ).truthy? rescue Error::Next => e e.code_value.truthy? end end self rescue Error::Break => e e.code_value end |
#code_replace(dictionary) ⇒ Object
2684 2685 2686 2687 2688 2689 |
# File 'lib/code/object/dictionary.rb', line 2684 def code_replace(dictionary) code_dictionary = dictionary.to_code self.raw = code_dictionary.raw.dup self end |
#code_right_associate(value) ⇒ Object
2930 2931 2932 2933 2934 2935 |
# File 'lib/code/object/dictionary.rb', line 2930 def code_right_associate(value) code_value = value.to_code pair = raw.detect { |_, entry_value| entry_value == code_value } pair ? List.new(pair) : Nothing.new end |
#code_select(argument, **globals) ⇒ Object
2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 |
# File 'lib/code/object/dictionary.rb', line 2723 def code_select(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) Dictionary.new( raw.select { |_, value| value.is_a?(code_argument.raw) } ) else Dictionary.new( raw.select.with_index do |(key, value), index| argument.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ).truthy? rescue Error::Next => e e.code_value.truthy? end ) end rescue Error::Break => e e.code_value end |
#code_select!(argument, **globals) ⇒ Object
2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 |
# File 'lib/code/object/dictionary.rb', line 2701 def code_select!(argument, **globals) code_argument = argument.to_code if code_argument.is_a?(Class) raw.select! { |_, value| value.is_a?(code_argument.raw) } else raw.select!.with_index do |(key, value), index| argument.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ).truthy? rescue Error::Next => e e.code_value.truthy? end end self rescue Error::Break => e e.code_value end |
#code_set(key, value) ⇒ Object
2793 2794 2795 2796 2797 2798 |
# File 'lib/code/object/dictionary.rb', line 2793 def code_set(key, value) code_key = key.to_code code_value = value.to_code raw[code_key] = code_value code_value end |
#code_shift ⇒ Object
2695 2696 2697 2698 2699 |
# File 'lib/code/object/dictionary.rb', line 2695 def code_shift pair = raw.shift pair ? List.new(pair) : Nothing.new end |
#code_size ⇒ Object
2800 2801 2802 |
# File 'lib/code/object/dictionary.rb', line 2800 def code_size Integer.new(raw.size) end |
#code_slice(*arguments) ⇒ Object
2804 2805 2806 2807 |
# File 'lib/code/object/dictionary.rb', line 2804 def code_slice(*arguments) code_arguments = arguments.to_code Dictionary.new(raw.slice(*code_arguments.raw)) end |
#code_store(key, value) ⇒ Object
2691 2692 2693 |
# File 'lib/code/object/dictionary.rb', line 2691 def code_store(key, value) code_set(key, value) end |
#code_to_context ⇒ Object
2817 2818 2819 |
# File 'lib/code/object/dictionary.rb', line 2817 def code_to_context Context.new(raw) end |
#code_to_dictionary ⇒ Object
2813 2814 2815 |
# File 'lib/code/object/dictionary.rb', line 2813 def code_to_dictionary self end |
#code_to_list ⇒ Object
2809 2810 2811 |
# File 'lib/code/object/dictionary.rb', line 2809 def code_to_list List.new(raw.map { |key, value| List.new([key, value]) }) end |
#code_to_query(namespace = nil) ⇒ Object
2821 2822 2823 2824 2825 |
# File 'lib/code/object/dictionary.rb', line 2821 def code_to_query(namespace = nil) code_namespace = namespace.to_code String.new(raw.to_query(code_namespace.raw)) end |
#code_transform_keys(function, **globals) ⇒ Object
2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 |
# File 'lib/code/object/dictionary.rb', line 2827 def code_transform_keys(function, **globals) code_function = function.to_code Dictionary.new( raw .map .with_index do |(key, value), index| [ code_function.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ), value.to_code ] rescue Error::Next => e [e.code_value, value.to_code] end .to_h ) rescue Error::Break => e e.code_value end |
#code_transform_keys!(function, **globals) ⇒ Object
2851 2852 2853 2854 |
# File 'lib/code/object/dictionary.rb', line 2851 def code_transform_keys!(function, **globals) self.raw = code_transform_keys(function, **globals).raw self end |
#code_transform_values(function, **globals) ⇒ Object
2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 |
# File 'lib/code/object/dictionary.rb', line 2856 def code_transform_values(function, **globals) code_function = function.to_code Dictionary.new( raw .map .with_index do |(key, value), index| [ key.to_code, code_function.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ) ] rescue Error::Next => e [key.to_code, e.code_value] end .to_h ) rescue Error::Break => e e.code_value end |
#code_transform_values!(function, **globals) ⇒ Object
2880 2881 2882 2883 |
# File 'lib/code/object/dictionary.rb', line 2880 def code_transform_values!(function, **globals) self.raw = code_transform_values(function, **globals).raw self end |
#code_update(*arguments, **globals) ⇒ Object
2680 2681 2682 |
# File 'lib/code/object/dictionary.rb', line 2680 def code_update(*arguments, **globals) code_merge!(*arguments, **globals) end |
#code_values(*arguments, **globals) ⇒ Object
2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 |
# File 'lib/code/object/dictionary.rb', line 2885 def code_values(*arguments, **globals) arguments = arguments.to_code.raw code_function = (arguments.last if arguments.last.is_a?(Function)).to_code arguments = arguments[..-2] unless code_function.nothing? entries = if arguments.empty? raw.to_a else arguments.map { |key| [key, raw.fetch(key, Nothing.new)] } end if code_function.nothing? List.new(entries.map(&:second)) else List.new( entries.map.with_index do |(key, value), index| code_function.call( arguments: List.new([key.to_code, value.to_code, index.to_code, self]), **globals ) rescue Error::Next => e e.code_value end ) end rescue Error::Break => e e.code_value end |
#code_values_at(*keys) ⇒ Object
2918 2919 2920 2921 2922 |
# File 'lib/code/object/dictionary.rb', line 2918 def code_values_at(*keys) code_keys = keys.to_code List.new(raw.values_at(*code_keys.raw)) end |
#present? ⇒ Boolean
2964 2965 2966 |
# File 'lib/code/object/dictionary.rb', line 2964 def present? raw.present? end |