Vector

From Esolang
Jump to navigation Jump to search

Vector is an OISC invented by User:None1, it uses a 3-dimensional vector.

Data

As said above, Vector uses a 3D vector called A, it is initially (0,0,0).

A vector literal is represented by 3 real numbers separated by spaces.

Command

B c D

B and D are 3D vectors, c is a real number. The command means: If A·B equals to c, then (add A by D and jump to the start of program).

There is an output command, it is not required so it does not count in the number of commands:

B c D E

(Print the value of A·E then add A by D and jump to the start of program) if A·B equals to c. Whether as number or as character depends on implementation.

Examples

Print HI

1 0 0 0 72 0 0
1 0 0 72 1 0 0 1 0 0
1 0 0 73 1 0 0 1 0 0

Infinite loop

0 0 0 0 0 0 0

nVector

Of course, we can use other dimensions instead of 3 dimensions, that gives us nVector (n is the dimension number).

Command(s) are the same as vector except that a vector literal uses n numbers instead of three.

Interpreters

Badly written by author in Python, 3D only but can be modified to support other dimensions:

import sys
k=sys.stdin.read().strip().split('\n')
acc=(0.0,0.0,0.0)
p=0
while p<len(k):
 kp=k[p]
 if len(kp.split())==7:
  a,b,c,d,e,f,g=list(map(float,kp.split()))
  if acc[0]*a+acc[1]*b+acc[2]*c==d:
   acc=(acc[0]+e,acc[1]+f,acc[2]+g)
   p=0
   continue
 else:
  a,b,c,d,e,f,g,h,i,j=list(map(float,kp.split()))
  if acc[0]*a+acc[1]*b+acc[2]*c==d:
   print(chr(int(acc[0]*h+acc[1]*i+acc[2]*j)),end='')
   acc=(acc[0]+e,acc[1]+f,acc[2]+g)
   p=0
   continue
 p+=1