BASIC Developer & Support Resources > Open Forum

RaspberryBASIC.org Forum

(1/58) > >>

John:
I have been ban from the RPi forum for giving a moderator my opinion what their job should be.  >:(

I'm now posting on the RaspberryBASIC.org forum with my RPi efforts. If you would like to join us there, register to be a member.

I created a challenge that tests a common program among 11 different languages. Attached is the results of that challenge. The code for each can be found on the RaspberryBASIC.org forum.

AIR:
Your bash code is doing string>int conversions.

I ran your original code on my macbook laptop (i5):

Middle
Plus:   1000000
Minus:  0

real    0m20.839s
user    0m19.425s
sys    0m1.391s

Then I ran an updated version where I eliminated the conversions:

Middle
Plus:   1000000
Minus:  0

real    0m16.380s
user    0m15.342s
sys    0m1.025s

The above were with Bash 3.2.57, which comes standard on macOS 10.13.6

Finally, I ran the updated script using Bash 5.0.11:

Middle
Plus:   1000000
Minus:  0

real    0m10.185s
user    0m10.060s
sys    0m0.108s

Updated script:


--- Code: Bash ---declare -i accum=0declare -i milvar=1000000 for i in {1..1000000}do  ((++accum))  ((--milvar))  if (( $accum == $milvar ));    then      echo "Middle"  fidone echo "Plus:  " $accumecho "Minus: " $milvar
AIR.

PS:  For giggles, I ran the updated script on my local Debian server (i7, Bash 5.0.3):

Middle
Plus:   1000000
Minus:  0

real    0m3.722s
user    0m3.665s
sys    0m0.057s

Didn't run this on my Pi, which is a 3B model and slow as crap...LOL

John:
Thanks AIR for the updated Bash script. I'll update the challenge with your submission. It would be great if you join us on the RasperryBASIC.org forum. We could use a mentor of your skill level.

I'm looking for Ruby, Rust and 8th submissions that are run on a RPi 4B. I can run the 8th submission if a binary is attached along with the source.

Update: I didn't realize Ruby comes pre-installed on the RPi.

jalih:

--- Quote from: John on November 26, 2019, 10:00:28 am ---
I'm looking for Ruby, Rust and 8th submissions that are run on a RPi 4B. I can run the 8th submission if a binary is attached along with the source.

--- End quote ---

Here is a 8th version using just the stack...

--- Code: ---: plus-minus
  n:1+
  swap
  n:1-
  swap
  2dup n:= if
    "Middle\n" .
  then ;

: app:main
  1000000 0
  ' plus-minus 1000000 times
  "Plus: %d\nMinus: %d\n" s:strfmt .
  bye ;

--- End code ---

RPI binary available here

John:
Thanks Jalih for the 8th submission! I'll update the forum and chart with your submission. Any chance of a round 3 submission that addresses arrays and strings?

Curious. Is your name pronounced like the month of July?

Navigation

[0] Message Index

[#] Next page

Go to full version