# Fabulous ! Operator

### Fabulous ! Operator

The operator ! is called the Fabulous Operator in z^3 language. It is a powerful creator of functions, and provides for absolutely simple notation!

For example, "x^2"! gives a function that takes x as a parameter, and squares the input variable.

In the basic form, "!" is meant to compute the factorial function, when used as a suffix to a number (or factorial compatible value such as BigInts, High Precision Decimals, Complex Numbers, etc.).

However, based on the arguments provided, it can simply create powerful *functions* with the simple notation of ! (to a string, regular expression, etc.). This dramatically simplifies notation to create functions, and makes for powerful and fabulously expressive code.

Because the "!" operator automatically figures out parameters of a function, it is also called Zero Shot Function Definition. To make it simpler, CODEAI can provide formulaic definition of a problem definition, that can simply be provided to fabulous operator to go from description to executable form directly.

The Operator ! can have multiple meanings, when used as a suffix. Of course, as a prefix, ! represents NOT as in most C like languages.

The Operator ! can be used to

(1) Compute factorial of numbers (including complex numbers etc),

(2) Create functions out of strings,

(3) Create predicate functions and search functions out of simple notations with regular expressions, strings, etc.

### Converting A String To A Function

A simple string can be converted to a function with ! operator, and parameters are detected automatically using z^3 rules.

"x^2"! ("x^2"!)(3) // could make ! binary with similar behavior too. 1..100.$("x^2"!) 1..100.$("SIN(x)"!) ("SIN(x)"!)(3,4) s="x^5"; g=(s!); g(34); s="x^5+y^4"; g=(s!); g(1,3); ("x^5+y^4+z^5"!)(2,3,4); MS(12).$$("SUM(x)"!) MS(1..12).$$("SUM(x)"!) a="x^4"; foured=(a!)#; foured(1..34) (["x^3","x^4"]!)@1..3 // did not work ("x^"|.+|1..10)!@(1..10) //this did not parse ("x^"|x+y|1..10)!@1..10 // also did not parse ("x+"|x+y|1..10)!@1..10

Simple predicate functions (functions that do simple boolean true/false checks) can be created with shortcut notations such as below:

"<1"!

("x<3"!)(2) ("x<3&&y>4"!)(2,5) "<'absc'"! "<=3"! ">=3"! "!=3"! ("x<3&&x>4"!)+"" ("SIN(x)"!)(35deg) "==(44)"! "==(44!)"! f1="FEQ(44!,x)"!; f1(43!)

The following shows the use of these simple function creations, with generated arrays to create a series of functions. For example, ((1..10|.+|"x")!) creates 10 functions from x+1, x+2, etc. until x+10. Below is a case where these array series of functions are applied to an array to the left of @ operator.

..5@((1..10|.+|"x+")!) ..50@((1..10|.+|"x^")!) 1..100.F(">50"!) // .F stands for .filter 1..100.F("x>5&&x<25"!)

## Other Examples

2..10|.%|1..5 // element wise modulo operator (1..10)@"SIN"! (1..100n)! // factorials work as usual (1+3i)!