RvsZ3

From ZCubes Wiki
Revision as of 03:09, 6 July 2021 by Devika (talk | contribs)
Jump to navigation Jump to search

Comparison of R vs Z3

Simple manipulations; numbers and vectors

Vectors and assignment

Z3 operates on named data structures. The simplest such structure is the numeric vector,which is a single entity consisting of an ordered collection of numbers. 

To set up a vector named x, say, consisting of five numbers, namely 10.4, 5.6, 3.1, 6.4 and 21.7, use the R command
 > x <- c(10.4, 5.6, 3.1, 6.4, 21.7)

Z3 command to set up a vector is:
 x<==[10.4, 5.6, 3.1, 6.4, 21.7];

Alternatively we can use the simple "=" also.
  x=[10.4, 5.6, 3.1, 6.4, 21.7]

Assignment can also be made using the function ASSIGN(). An equivalent way of making the same assignment as above is with:
In R,
> assign("x", c(10.4, 5.6, 3.1, 6.4, 21.7))

In Z3 to use the "ASSIGN" function as:
ASSIGN("x", [10.4, 5.6, 3.1, 6.4, 21.7])

Assignments can also be made in the other direction, using the obvious change in theassignment operator. 
So the same assignment could be made using
 [10.4, 5.6, 3.1, 6.4, 21.7]==>x 

The reciprocals of the above five values for x in R,
> 1/x
In Z3, We can use the function called Reciprocal,
"RECIPROCAL(x)" (the value of x is [10.4, 5.6, 3.1, 6.4, 21.7]

Also we can use directly,
 ([10.4,5.6,3.1,6.4,21.7]<>d40)@(x=>1/x)

Please check back in couple of days. We are updating the page.