Author Topic: Nimrod  (Read 22910 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Nimrod - FizzBuzz Test
« Reply #15 on: September 24, 2013, 05:41:34 PM »
Quote
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Code: [Select]
# Fizz Buzz program

const f = "Fizz"
const b = "Buzz"
for i in 1..100:
  if i mod 15 == 0:
    echo f, b
  elif i mod 5 == 0:
    echo b
  elif i mod 3 == 0:
    echo f
  else:
    echo i

jrs@laptop:~/nimrod/examples$ nimrod c -d:release fizzbuzz.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: fizzbuzz [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/fizzbuzz.o examples/nimcache/fizzbuzz.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/system.o examples/nimcache/system.c
gcc   -o /home/jrs/nimrod/examples/fizzbuzz  examples/nimcache/system.o examples/nimcache/fizzbuzz.o  -ldl
Hint: operation successful (7452 lines compiled; 1.390 sec total; 8.870MB) [SuccessX]

Results
Code: [Select]
jrs@laptop:~/nimrod/examples$ ./fizzbuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz
jrs@laptop:~/nimrod/examples$

kryton9

  • Guest
Re: Nimrod
« Reply #16 on: September 24, 2013, 06:02:15 PM »
I can't get any programming language to run 100% in Ubuntu other than Code::Blocks and gcc and g++ stuff.
Anyways your nimrod work is really making me want to get it working. I will try in Windows7 next.

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #17 on: September 24, 2013, 06:47:54 PM »
Kent,

How I got Nimrod to work.

1. Unzip archive into your ~/nimrod directory. (~ = /home/jrs for me)

2. I ran sh build64.sh which created the nimrod executable in my ~/nimrod/bin directory.

3. I then export PATH=$PATH:/home/jrs/nimrod/bin

I can then run nimrod from the examples directory or where ever I wish.

Nimrod may have some dependencies that need to installed first.

Advice: Get comfortable working in a console and using Linux console mode utilities. I use Nautilus for my file manager and Evolution for my mail client. I use Gimp for my Photoshop replacement and ssh/sftp for connecting to other servers and Firefox as my browser.  I spend 90% of my development time in a console environment.


 
« Last Edit: September 24, 2013, 08:36:27 PM by John »

kryton9

  • Guest
Re: Nimrod
« Reply #18 on: September 24, 2013, 09:30:53 PM »
I just got frustrated not getting anything to work as I expected.

I got nimrod and aporia installed and running in windows :)

Going to test out some of your examples now, thanks for putting them up.

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #19 on: September 24, 2013, 09:44:42 PM »
That's it. I'm calling Linus and have you put on the list.

Windows backslider!


kryton9

  • Guest
GLFW Nimrod for Windows
« Reply #20 on: September 24, 2013, 10:02:00 PM »
I love it, thanks for the laughs John.

Your examples here helped test my setup.  I got the cairo example to work just fine, but had problems with the glfw example.

For windows, I downloaded the wrapper from here: https://github.com/rafaelvasco/nimrod-glfw  just click on the download zip button.
Once extracted you will have 2 subfolders:
src and test

of course substitute your path to your Nimrod directory, mine is D:\Nimrod
from the src folder, take the glfw.nim file and copy or move it to your D:\Nimrod\lib\wrappers directory.
from the test folder, I copied the glfw.dll to the D:\Nimrod\dist directory
from the test folder, I copied the glfwtest.nim to the D:\Nimrod\examples directory

If you do the above, then it should compile and run just fine.

Once I get all the dependencies and tests working, I will try to make a bundle download for Windows where everything is setup right from the get go without having to hunt dependencies for aporia and nimrod, that would include all the gtk+ stuff too.
« Last Edit: September 24, 2013, 10:16:31 PM by kryton9 »

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #21 on: September 24, 2013, 10:02:16 PM »
Quote
Going to test out some of your examples now, thanks for putting them up.

I would install Gtk3 rather than Gtk2 under Windows. They compiled the Gtk3 version with MinGW-gcc and it runs a lot smoother.

I haven't looked what is needed yet to get theme support working under Windows with Nimrod. Should be pretty easy.

kryton9

  • Guest
Re: Nimrod
« Reply #22 on: September 24, 2013, 10:07:44 PM »
I am worried about the gtk3+ dependencies, like sourceview, libxml etc. Once I get everything working and a bundle figured out. Then I won't be afraid to try out GTK3 John, thanks I didn't know it was out and working with Nimrod.

kryton9

  • Guest
Re: Nimrod - FizzBuzz Test
« Reply #23 on: September 24, 2013, 10:11:24 PM »
Quote
The "Fizz-Buzz test" is an interview question designed to help filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag. The text of the programming assignment is as follows:

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Amazing how easy the code is and nice to look at, to do, what it does!

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #24 on: September 24, 2013, 10:13:26 PM »
Can you post a screen shot of your Nimrod Aporia IDE running on Windows?


kryton9

  • Guest
Screenshot Aporia on Windows
« Reply #25 on: September 24, 2013, 10:21:36 PM »
Here is a screenshot of Aporia running in Windows 7.

I really like this IDE!

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #26 on: September 24, 2013, 10:23:47 PM »
Sweet!

kryton9

  • Guest
Re: Nimrod
« Reply #27 on: September 24, 2013, 10:27:20 PM »
I got to get some sleep, have a great evening John. I can sleep well knowing I got Nimrod and Aporia to come home to further play with tomorrow evening. THanks for your help!

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Re: Nimrod
« Reply #28 on: September 24, 2013, 10:48:50 PM »
The Nimrod language/translator is written Nimrod (bootstrapped from Pascal) so when you get through playing with the examples I posted, maybe we'll see some k9.nim extensions from you.  8)

Offline John

  • Forum Support / SB Dev
  • Posts: 2345
    • ScriptBasic Open Source Project
Nimrod - Towers of Hanoi
« Reply #29 on: September 25, 2013, 12:09:43 AM »
Quote
The Tower of Hanoi (also called the Tower of Brahma or Lucas' Tower and sometimes pluralised) is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:
  • Only one disk must be moved at a time.
  • Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod.
  • No disk may be placed on top of a smaller disk.

With three disks, the puzzle can be solved in seven moves.

Code: [Select]
proc hanoi(disks: int, fromTower: string, toTower: string, viaTower: string) =
  if disks != 0:
    hanoi(disks - 1, fromTower, viaTower, toTower)
    echo("Move disk ", disks, " from ", fromTower, " to ", toTower)
    hanoi(disks - 1, viaTower, toTower, fromTower)
 
hanoi(3, "1", "2", "3")

jrs@laptop:~/nimrod/examples$ nimrod c -d:release hanoi.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hanoi [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o examples/nimcache/hanoi.o examples/nimcache/hanoi.c
gcc   -o /home/jrs/nimrod/examples/hanoi  examples/nimcache/system.o examples/nimcache/hanoi.o  -ldl
Hint: operation successful (7445 lines compiled; 0.266 sec total; 8.870MB) [SuccessX]
jrs@laptop:~/nimrod/examples$ ./hanoi
Move disk 1 from 1 to 2
Move disk 2 from 1 to 3
Move disk 1 from 2 to 3
Move disk 3 from 1 to 2
Move disk 1 from 3 to 1
Move disk 2 from 3 to 2
Move disk 1 from 1 to 2
jrs@laptop:~/nimrod/examples$
« Last Edit: September 25, 2013, 12:38:45 AM by John »