Started yesterday. Easily hackable (please don't do that). I'll come up with nice problems, I promise. Will be open source once I understand 4clojure's license. Enjoy!
I'll delete everything without a notice, all your logins there, your solutions, everything, because currently it is not secure. I have a script to install everything from scratch quickly.
The exercises are for Nim even if the starting page says otherwise.
Peter
Only 2-3 testers, and the most complex code is:
import os
for kind, path in walkDir("/"):
echo(path)
Well... At least they used 2 spaces instead of 4...
Come on! The 4clojure was an excellent experiment for me, I try to bring it to Nim as well.
Thank you for testing. About the timeline: I'll try to have an update this weekend. I'm working on the site, security, and the problems. I'll upload everything to github within a week. I was very surprised how quickly I could make the basic page work. My estimate is that we could have a working site with a nice set of problems within 3 weeks. I'm owning the 4nim.org domain.
Let me write about my plans, why I'm so excited about this site. Eventually I would like to have the following set of problems:
At the end we should have the same amount (around 150) of problems as 4clojure has.
Peter
That's really cool!
Is this still written in Clojure? if so, will it be written in Nim? ;)
@dom96 Yes, it is still in clojure. I'm trying to make it cool first :)
It looks like Codemirror (JS editor) is not supporting Nim. The supported list is https://codemirror.net/mode/index.html . Do any of you know any other js editor solution which supports Nim, or what can I offer for a volunteer in return? :)
Peter
I'm making small progress. Updated the site with 24 problems. Please check if you have some time, and give feedback.
So, the first problem says:
This is the first Nim exercise. The expression you enter below will be copied to all the __ positions. Your task is to have all the assert check be true. Don't over think it!
assert 2 == 1 __ 1
assert 3 == 1 __ 2
I entered:
assert 2 == 1 + 1
assert 3 == 1 + 2
And got:
Hint: system [Processing] Hint: test [Processing] test.nim(1, 22) Error: expression ' if false: failedAssertImpl("true ")' has no type (or is ambiguous)
@kirbyfan64sos First of all, please don't give up. You should not replace "__" in the unit tests, but rather write your solution (+) to the text area.
Peter
Hey, Well then i think the same way as kirby... those were mine too xD
@oderWat ah k that explains it... try it as soon im home
Panda
import sequtils
var firstElement = x[0]
var lastIndex = len(x) - 1
x.delete(0)
var lastElement = x.pop()
x.insert(lastElement, 0)
x.insert(firstElement, lastIndex)
@xhevahir On 4clojure I followed other users (we have that feature too because I copied that site, but we don't have anybody to follow yet) and checked their solutions after I solved a problem. I learned a lot this way. By the way, my solution to this particular exercise is:
var t = x[0]
x[0] = x[^1]
x[^1] = t
You can probably solve it in one line.
Let me write some general comments about the site. Thank you all for testing it, I really appreciate it.
I'll give more guideline how to use the site (and I'm going to disable the html editing of the unit tests, so you won't be able to replace "__" with "+").
The current 24 problems are just a shell, they contain very easy and very hard tasks as well. Don't feel bad if you a task looks impossible to solve, there are many missing intermediate steps.
I haven't created a secure sandbox yet. I can see two ways to do it. We could disable {.importc.}, import, and some proc from system.nim (but how to filter macros?), and then run the code. Or just run any given code in a virtual environment, and hope for the best.
About the exercises: 4Clojure pushed the functional approach. I don't want to do the same, at least not now (there are several ongoing threads about sequtils, copy-free lambda lifting, etc.). So I'm focusing on meta-programming exercises right now, because I believe that it is Nim's best feature.
I haven't put it on github, but I'll do so. If you want to help in developing, then I'll do it right now.
Peter
We could disable {.importc.}, import, and some proc from system.nim (but how to filter macros?), and then run the code.
Then probably asm statements too.