Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
What determines purity in FunC? Read/Write Functions

What determines the purity of a function?

A) It must only read the function parameters.
B) It can read values outside of the function parameters and return a value that depends on the parameters.
C) It can read values outside of the function parameters, but the return value must be independent of global data.

In all three cases, the function does not modify data outside of its scope.

https://t.me/tondev_eng/1876

  
  
Posted one year ago
Votes Newest

Answers


In the context of the FunC language, the three options define the concept of a pure function.

A pure function is a function that:

A) Only reads the values passed to it as parameters and does not access any external state. This means that its output is solely determined by its input parameters.

B) Can read values outside of the function parameters, but its output still depends only on the values passed to it as parameters. It does not rely on any external state or global data.

C) Can read values outside of the function parameters, but its output must be independent of any global data. This means that it should not use or depend on any global variables or data.

These definitions of a pure function help ensure that a function's output is predictable and consistent, making it easier to understand, test, and debug.


Practically:
a) ""impure"" modifier present - guarantees correct behaviour
b) ""impure"" modifier absent - FunC compiler will do strange things, such as strip out some code without your permission.

It will silently remove the function call in two cases:
a) function returns nothing:
() fun() { }

b) function returns something, but this something is not assigned to anything:

(int) fun() { return 5; }
...
int a = fun(); ;; fun is called
fun(); ;; fun call is removed"
  
  
wiki
Posted one year ago
Edited one year ago