SetContains

Whether a set contains a value.

Declaración

Sintaxis

SetContains(expr left, expr right, ttype type, expr? value)

Argumentos

Argument

Descripción

left

the set.

right

the value looked for.

type

the logical type of the result.

value

the compile time value of the expression, when the frontend could fold it; nil otherwise.

Valores devueltos

The value of the expression.

Descripción

x in s. This is the operation a set exists for, and it does not depend on the number of elements the way ListContains does.

Ejemplos

(SetContains
  :left (Var
    :v (SymbolRef 1 "s")
  )
  :right (IntegerConstant
    :n 1
    :type (Integer
      :kind 4
    )
    :intboz_type :Decimal
  )
  :type (Logical
    :kind 4
  )
  :value nil
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "i" (Variable
              :parent_symtab 1
              :name "i"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "p" (Variable
              :parent_symtab 1
              :name "p"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Logical
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "s" (Variable
              :parent_symtab 1
              :name "s"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Set
                :type (Integer
                  :kind 4
                )
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (Assignment
            :target (Var
              :v (SymbolRef 1 "s")
            )
            :value (SetConstant
              :elements [
                (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                (IntegerConstant
                  :n 2
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
              ]
              :type (Set
                :type (Integer
                  :kind 4
                )
              )
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "i")
            )
            :value (SetLen
              :arg (Var
                :v (SymbolRef 1 "s")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "p")
            )
            :value (SetContains
              :left (Var
                :v (SymbolRef 1 "s")
              )
              :right (IntegerConstant
                :n 1
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "i")
            )
            :value (SetPop
              :a (Var
                :v (SymbolRef 1 "s")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (SetInsert
            :a (Var
              :v (SymbolRef 1 "s")
            )
            :ele (IntegerConstant
              :n 3
              :type (Integer
                :kind 4
              )
              :intboz_type :Decimal
            )
          )
          (SetRemove
            :a (Var
              :v (SymbolRef 1 "s")
            )
            :ele (IntegerConstant
              :n 2
              :type (Integer
                :kind 4
              )
              :intboz_type :Decimal
            )
          )
          (SetClear
            :a (Var
              :v (SymbolRef 1 "s")
            )
          )
        ]
      )
    }
  )
  :items []
)

Ver también

Set, ListContains, DictContains