import tables, options, sugar | |
type | |
Constraint*[V, D] = ref object | |
# Base class for all constraints | |
variables*: seq[V] # The variables that the constraint is between | |
satisfied*: proc (assignment: Table[V, D]): bool | |
Csp*[V, D] = object | |
# A constraint satisfaction problem consists of variables of type V |
import asynchttpserver, asyncdispatch, os | |
proc handler(req: Request) {.async.} = | |
echo "request for path ", req.url.path | |
let cwd = getCurrentDir() | |
let file = cwd / req.url.path | |
if fileExists(file): | |
await req.respond(Http200, file.readFile()) | |
else: |
# nim c -r --threads:on --gc:orc | |
import cpuinfo, os, random, locks, deques | |
type | |
WorkReq = ref object | |
id: int | |
WorkRes = ref object | |
id: int |
- @ashwinvis
- https://reddit.com/user/salamipull
- @quantum5
- @Vusys
- @jaszhix
Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct
Tested this sample with Nim 1.0.6 on Windows 8.1
- Install Nim Game Library
nimble install nimgl
- Get glfw3.dll Go to GLFW web site, go to Download page and download Windows pre-compiled binaries. Unzip it and copy glfw3.dll to where you run sample program.
I have a pet project I work on, every now and then. CNoEvil.
The concept is simple enough.
What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?
Note 1: This tutorial is for Linux users only, but if you understand the idea, you can use it on all systems and it will work as required :).
- Compile Nim-lang code as a (C/C++ header File). THIS IS WHAT WE WILL TAKE TODAY.
- Compile Nim-lang code as a (C/C++ static library).
- Compile Nim-lang code as a (C/C++ dynamic library).