đ
Run everywhere
Vif is built on top of typescript. It can run on (almost) all IDE.
npx init-vif
const Fibonacci_Suite_Until_10 = <T>(OnFibNumber: (FibNumber: number) => T): T[] =>
new Array(9)
.fill(1)
.reduce((arr, _, i) => {
arr.push((i <= 1) ? i : arr[i - 2] + arr[i - 1])
return arr
}, [])
.map(OnFibNumber)
const MyFb = new Fb({
interface: {
static: {
Fibonacci_Array_Until_10: ArrayFrom(34, () => new Bool())
}
},
body() {
return [
...Fibonacci_Suite_Until_10((FibNumber) => new Assign(this.static.Fibonacci_Array_Until_10[FibNumber as UNSAFE_INDEX], true)),
// Only for simulations
...Fibonacci_Suite_Until_10((FibNumber) => new UnitTest(
`Checking index ${FibNumber} ...`,
this.static.Fibonacci_Array_Until_10[FibNumber as UNSAFE_INDEX], "=", true)
),
...Fibonacci_Suite_Until_10((FibNumber) => new UnitLog(`\x1b[0;3${FibNumber}m A cool log!`))
]
}
})
const MyFb = new Fb({
interface: {
static: {
Fibonacci_Array_Until_10: ArrayFrom(34, () => new Bool())
}
},
body() {
return [
...(() => {
let n1 = 0
let n2 = 1
let nextTerm
let assign_operations = []
let unit_operations = []
let log_operations = []
for (let i = 1; i <= 10; i++) {
assign_operations.push(new Assign(this.static.Fibonacci_Array_Until_10[i as UNSAFE_INDEX], true))
// Only for simulations
unit_operations.push(new UnitTest(
`Checking index ${i} ...`,
this.static.Fibonacci_Array_Until_10[i as UNSAFE_INDEX], "=", true
))
log_operations.push(new UnitLog(`\x1b[0;3${i}m A cool log!`))
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm
}
return [assign_operations, unit_operations].flat()
})()
]
}
})