nim seems to be fast But it seems to be similar to Python, so let's try it. Jupyter Kernel is not. Made with docker.
To install docker, see Install Docker Engine.
Do the following to start Jupyter.
bash
docker run -it --rm -p 8888:8888 tsutomu7/nim
Open "docker host IP address: 8888" in your browser. Select "nim" from "New" in the upper right.
You can write a nim program in a cell and run it with Shift + Enter.
nim
echo "Hello world!"
>>>
Hello world!
A list of commands is displayed with "?".
nim
?
>>>
?
!command
%run file
%time ...
%def ...
%inc ...
%web
You can execute shell commands by starting with "!".
nim
!echo 'echo "OK"' >> test.nim
You can run the file with "% run [optional] filename".
nim
%run test
>>>
OK
nim
%run --opt:size test
>>>
OK
You can measure the execution time with "% time [option]".
nim
%time
echo "OK?"
>>>
OK?
real 0m 0.00s
user 0m 0.00s
sys 0m 0.00s
You can create a program file with "% def name".
nim
%def hello
proc Hello(): string = "Hello!"
>>>
Created hello.nim
nim
%def world
proc World(): string = "World!"
>>>
Created world.nim
You can import and execute a file with "% inc name 1 name 2 ...".
nim
%inc hello world
echo Hello() & World()
>>>
Hello!World!
Display the URL of the document with "% web".
nim
%web
>>>
http://nim-lang.org/documentation.html
reference
--Document http://nim-lang.org/documentation.html --Tutorials, etc. http://nim-lang.org/learn.html --gist sample https://gist.github.com/miyakogi/b1df00c8bc99927d9d0d
that's all
Recommended Posts