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
Is there something like is_int in FunC?

Some programming languages have built-in functions like is_int() helping to check quickly if a specific variable is of type integer or not. Is there something like that in FunC?


This question was imported from Telegram Chat: https://t.me/tondev/85946

  
  
Posted one year ago
Votes Newest

Answers


Unfortunately, we don't have the built-in function like that.

However, you can create your own function to check if a value is an integer. Or you can take a reference here to acheive it.

forall X -> int is_null(X x) asm "ISNULL";
forall X -> int is_int(X x) asm "<{ TRY:<{ 0 PUSHINT ADD DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS";
forall X -> int is_cell(X x) asm "<{ TRY:<{ CTOS DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS";
forall X -> int is_slice(X x) asm "<{ TRY:<{ SBITS DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS";
forall X -> int is_tuple(X x) asm "ISTUPLE";

Remember, FunC's type system will usually make it unnecessary to check for a specific type at runtime, as the type constraints are already imposed at the compilation level.

For instance, if a function is designed to accept only integers as input, the compiler will enforce this requirement, and an error will be thrown if a non-integer is passed.

  
  
Posted one year ago
Howard Peng
10 × 1 Administrator