Kronecker product based fractals: Difference between revisions

Added 11l
(Added 11l)
Line 54:
See implementations and results below in JavaScript, PARI/GP and R languages. They have additional samples of "H", "+" and checkerboard fractals.
<br><br>
 
=={{header|11l}}==
{{trans|Nim}}
 
<lang 11l>F kroneckerProduct(a, b)
V m = a.len
V n = a[0].len
V p = b.len
V q = b[0].len
V result = [[0] * (n * q)] * (m * p)
L(i) 0 .< m
L(j) 0 .< n
L(k) 0 .< p
L(l) 0 .< q
result[i * p + k][j * q + l] = a[i][j] * b[k][l]
R result
 
F kroneckerPower(m, n)
V result = m
L(i) 2 .. n
result = kroneckerProduct(result, m)
R result
 
F to_str(m)
V result = ‘’
L(row) m
L(val) row
result ‘’= I val == 0 {‘ ’} E ‘ *’
result ‘’= "\n"
R result
 
V a1 = [[0, 1, 0], [1, 1, 1], [0, 1, 0]]
print(‘Vicsek fractal:’)
print(to_str(kroneckerPower(a1, 4)))
print()
V a2 = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]
print(‘Sierpinski carpet fractal:’)
print(to_str(kroneckerPower(a2, 4)))</lang>
 
{{out}}
The same as in Nim solution.
 
=={{header|Ada}}==
1,481

edits