Skip to content

Commit

Permalink
modernize example to Nim 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mashingan committed May 9, 2024
1 parent 5b665aa commit ac9e970
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 3 additions & 1 deletion coroexample.nim
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ proc main =
break
else:
echo "Now contention of writing"
let sleeping = 300.random
let sleeping = rand 300
suspend()
sleepTotal += sleeping
sleep sleeping
)
let startTime = cpuTime()
run()
producer.wait()
consumer.wait()
echo "The cpuTime needed is ", cpuTime() - startTime, " with sleeping ",
sleepTotal, " ms."

Expand Down
6 changes: 3 additions & 3 deletions enumerate_datestr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Initial problem was asked in the forum https://forum.nim-lang.org/t/3005
# and this is the result of solution.

import times, strformat
import std/[times, strformat]

template iterdays(ds1, ds2: string, op: untyped): untyped =
var
Expand All @@ -12,10 +12,10 @@ template iterdays(ds1, ds2: string, op: untyped): untyped =
var interval: TimeInterval
# yield day-by-day
if d1.monthday != d2.monthday:
interval = initInterval(hours=24)
interval = initTimeInterval(hours=24)
# yield month-by-month
else:
interval = initInterval(months=1)
interval = initTimeInterval(months=1)

while `op`(d1.toTime, d2.toTime):
yield d1
Expand Down
7 changes: 3 additions & 4 deletions front-end-karax/server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ var
logins = newTable[string, bool]()
counts = 0
#menu = @["profil", "statistics", "information"]
menu = [("profile", "#/profile"),
("statistics", "#/statistics"),
("information", "#/information")].mapIt(
Menu(label: it[0], href: it[1]))
menu = ["profile", "statistics", "information"].mapIt(
Menu(label: it, href: &"#/{it}")
)

routes:
get "/managing":
Expand Down

0 comments on commit ac9e970

Please sign in to comment.