Zblack Example of Omniglot

From ZCubes Wiki
Jump to navigation Jump to search

Zblack Example of Omniglot

In zblack, a foreign programming language file can be run simply by include() call.

Consider the following files. Here when omniglot1.z3 is run, the programs with different languages are run intermixed to give the output given at the end.

Also note that include("test.apl") is commented below, however, if you have APL Kernel installed, it will also trigger.

Note that .ts file transpiles to js, and is run in the z^3 space itself. Python, APL, etc. are run on the server side, and z^3 runs those languages via Kernels installed at the connected server. To achieve these connections, provide an app.json file on the same folder as omniglot1.z3 file.

app.json

The following values are obtained by running

jupyter lab

The values of the config comes from the line (example) in the command window which launches the jupyter kernels.

http://localhost:8889/lab?token=ebbd63a8642c6788a974dcf2f00ecb06341ef009d9a31bc4

Example Jupyter Screen

The values are filled into the app.json. token can be dynamic, or a more permanent password (if setup appropriately).

{
	"ZAPICONFIGS":
		{
			"JUPYTER":
			{
				"url"	:"http://localhost",
				"port"	:"8889",
				"token"	:"fddfb4adf2c44c33bb362cd13ba70eb54558b50f9a16032e"
			}
		}
}


omniglot1.z3

var end=SUM(SIN(1..340));
var end1=SUM(COS(1..30));
var end2=SUM(1..30);
console.log(end);
console.log(end1);
console.log(end2);

include("test1.py");
// include("test.apl");
include("test.ts");
include("test.py");
include("test3.py");
include("test4.py");

test1.py

Notice the [= =] operator to provide the expression composed of variables from omniglot1.z3


import time
import datetime

index=0;
for _ in range(2):
    for i in range(2):
        # get the current date and time
        now = datetime.datetime.now()
        index=index+1
        print("time",now,"i",i,"index",index)
    time.sleep(1)
1+2+3+4+[= end*end1*4+end2 =]
	

test1.apl

Not triggered in this case, but it can be uncommented in z^3 code to be run.

+⌿ 1 2 3 4 5 6
	


test.ts

Typescript

// Defining an interface
interface Person {
  name: string;
  age: number;
  occupation?: string; // Optional property
}

// Function with type annotations
function greet(person: Person): string {
  return `Hello, ${person.name}! You are ${person.age} years old.`;
}

// Creating an object that satisfies the interface
const john: Person = {
  name: "John Doe",
  age: 30,
  occupation: "Software Engineer"
};

// Calling the function and printing the result
console.log(greet(john));

// Using an enum
enum Status {
  Pending = "pending",
  InProgress = "in_progress",
  Completed = "completed"
}

// Function using the enum
function updateStatus(id: number, status: Status): string {
  return `Task ${id} status updated to ${status}`;
}

console.log(updateStatus(1, Status.InProgress));

test.py

import math
[34,math.sin(34)]


test3.py

import math
[43,math.sin(43)]

test4.py

Python program prints out a string {= =} with z^3 code which triggers computation on the side of z^3 code.

import math
math.sin(4.3)
x=4+5+6
x
#print(x,"{=SIN(1..",x,")=}")
print(x,"{=SIN(1..",x,")=}")

Output when omniglot1.z3 is run

Python program prints out a string {= =} with z^3 code which triggers computation on the side of z^3 code.

Output from Omniglot1 z^3 Program

See Also

OmniGlot