From b6f6cb19848d885efbe69dc11a25c9e9a3b2d062 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 23 Feb 2020 22:39:08 -0600 Subject: made fib.sh not just pseudo-code --- share/hackvr/examples/fib.sh | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) mode change 100644 => 100755 share/hackvr/examples/fib.sh (limited to 'share') diff --git a/share/hackvr/examples/fib.sh b/share/hackvr/examples/fib.sh old mode 100644 new mode 100755 index 9a9cf5c..c1d87ab --- a/share/hackvr/examples/fib.sh +++ b/share/hackvr/examples/fib.sh @@ -1,12 +1,24 @@ -#!/bin/sh -s=1 1 2 3 5 8 13 -x=0 0 1 0 -5 -5 -y=0 1 0 -3 -3 0 - -for i in 1 1 2 3 5 8 13 21 34 55 89;do - x=0 - y=0 - w=i - h=i - addshape 2 4 x y 0 x+w y 0 x+w y+h 0 x y+h 0 +#!/usr/bin/env bash +z=0 +a=1 +b=1 + +for i in $(seq 1 10);do + if [ $[$i % 2] = 0 ];then + x=$[$z] + y=0 + else + x=0 + y=$[$z] + fi + + w=$a + h=$a + + echo fib_$a addshape 2 4 $x $y 0 $[$x+$w] $y 0 $[$x+$w] $[$y+$h] 0 $x $[$y+$h] 0 + z=$a + s=$[$a+$b] + a=$b + b=$s + done -- cgit v1.2.3