Skip to content

Commit

Permalink
Fix vor Nim 0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Jun 7, 2016
1 parent b14c9e7 commit b6a2d3c
Show file tree
Hide file tree
Showing 32 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion abstract_type.nim
@@ -1,4 +1,4 @@
# In Nimrod type classes can be seen as an abstract type. Type classes specify
# In Nim type classes can be seen as an abstract type. Type classes specify
# interfaces, which can be instantiated by concrete types.
type
Comparable = concept x, y
Expand Down
2 changes: 1 addition & 1 deletion avglooplength.nim
@@ -1,4 +1,4 @@
import math, strfmt
import math, random, strfmt
randomize()

const
Expand Down
2 changes: 1 addition & 1 deletion balanced.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc shuffle(s: var string) =
Expand Down
2 changes: 1 addition & 1 deletion bogosort.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc shuffle[T](x: var openarray[T]) =
Expand Down
2 changes: 1 addition & 1 deletion break.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

while true:
Expand Down
2 changes: 1 addition & 1 deletion bullsandcows.nim
@@ -1,4 +1,4 @@
import math, strutils, rdstdin
import random, strutils, rdstdin
randomize()

proc random(a: string): char = a[random(0..a.len)]
Expand Down
2 changes: 1 addition & 1 deletion dayoftheweek.nim
Expand Up @@ -5,6 +5,6 @@ timeinfo.monthday = 25
timeinfo.month = mDec
for year in 2008..2121:
timeinfo.year = year
if getLocalTime(timeInfoToTime timeinfo).weekday == dSun:
if getLocalTime(toTime timeinfo).weekday == dSun:
stdout.write year," "
echo ""
2 changes: 1 addition & 1 deletion diningphilosophers.nim
@@ -1,4 +1,4 @@
import locks, math, os
import locks, random, os
randomize()

type Philosopher = ref object
Expand Down
2 changes: 1 addition & 1 deletion evolutionary.nim
@@ -1,4 +1,4 @@
import math, os
import random, os
randomize()

const
Expand Down
2 changes: 1 addition & 1 deletion fiveweekends.nim
Expand Up @@ -11,7 +11,7 @@ for year in 1900..2100:
for month in LongMonths:
timeinfo.year = year
timeinfo.month = month
if getLocalTime(timeInfoToTime timeinfo).weekday == dFri:
if getLocalTime(toTime timeinfo).weekday == dFri:
echo month," ",year
none = false
if none: inc sumNone
Expand Down
2 changes: 1 addition & 1 deletion forestfire.nim
@@ -1,4 +1,4 @@
import math, os, strutils
import random, os, strutils
randomize()

type State = enum Empty, Tree, Fire
Expand Down
2 changes: 1 addition & 1 deletion game24.nim
@@ -1,4 +1,4 @@
import math, strutils, algorithm, sequtils
import random, strutils, algorithm, sequtils
randomize()

template newSeqWith(len: int, init: expr): expr =
Expand Down
3 changes: 1 addition & 2 deletions gameoflife.nim
@@ -1,5 +1,4 @@
import os, strutils, math

import os, strutils, random
randomize()

var w, h: int
Expand Down
3 changes: 1 addition & 2 deletions guessthenumber.nim
@@ -1,5 +1,4 @@
import math, rdstdin, strutils

import random, rdstdin, strutils
randomize()

let iRange = 1..100
Expand Down
2 changes: 1 addition & 1 deletion htmltable.nim
@@ -1,4 +1,4 @@
import math, htmlgen
import random, htmlgen
randomize()

template randTD(): expr = td($random(1000..9999))
Expand Down
2 changes: 1 addition & 1 deletion lastfriday.nim
Expand Up @@ -3,7 +3,7 @@ import times, os, strutils
let year = paramStr(1).parseInt
for month in mJan .. mDec:
for day in countdown(getDaysInMonth(month, year), 1):
let t = getGMTime timeInfoToTime TimeInfo(second: 0, minute: 0, hour: 12,
let t = getGMTime toTime TimeInfo(second: 0, minute: 0, hour: 12,
monthday: day, month: month, year: year, tzname: "GMT")
if t.weekday == dFri:
echo t.format "yyyy-MM-dd"
Expand Down
2 changes: 1 addition & 1 deletion lastsunday.nim
Expand Up @@ -3,7 +3,7 @@ import times, os, strutils
let year = paramStr(1).parseInt
for month in mJan .. mDec:
for day in countdown(getDaysInMonth(month, year), 1):
let t = getGMTime timeInfoToTime TimeInfo(second: 0, minute: 0, hour: 12,
let t = getGMTime toTime TimeInfo(second: 0, minute: 0, hour: 12,
monthday: day, month: month, year: year, tzname: "GMT")
if t.weekday == dSun:
echo t.format "yyyy-MM-dd"
Expand Down
2 changes: 1 addition & 1 deletion mazegeneration.nim
@@ -1,4 +1,4 @@
import math, sequtils, strutils
import random, sequtils, strutils
randomize()

template newSeqWith(len: int, init: expr): expr =
Expand Down
2 changes: 1 addition & 1 deletion montecarlo.nim
@@ -1,4 +1,4 @@
import math
import random, math
randomize()

proc pi(nthrows: float): float =
Expand Down
2 changes: 1 addition & 1 deletion montyhall.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc shuffle[T](x: var seq[T]) =
Expand Down
2 changes: 1 addition & 1 deletion nosqr.nim
Expand Up @@ -3,7 +3,7 @@ import math
proc nosqr(n: int): seq[int] =
result = @[]
for i in 1..n:
result.add(i + round(sqrt(float(i))))
result.add(i + int(round(sqrt(float(i)))))

proc issqr(n: int): bool =
let sqr = sqrt(float(n))
Expand Down
2 changes: 1 addition & 1 deletion oneofnlines.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc oneOfN(n: int): int =
Expand Down
2 changes: 1 addition & 1 deletion playingcards.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc shuffle[T](x: var seq[T]) =
Expand Down
2 changes: 1 addition & 1 deletion randomcircle.nim
@@ -1,4 +1,4 @@
import tables, math, strutils, complex
import tables, random, strutils, complex
randomize()

proc random[T](a: openarray[T]): T =
Expand Down
2 changes: 1 addition & 1 deletion randomelement.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc random[T](a: openarray[T]): T =
Expand Down
11 changes: 8 additions & 3 deletions rcrename.nim
@@ -1,4 +1,4 @@
import httpclient, strutils, json, re, os
import httpclient, strutils, json, re, os, tables

## This code was used to convert all mentions of Nimrod to Nim on Rosetta Code
## automatically.
Expand Down Expand Up @@ -67,9 +67,14 @@ for catMember in titlesJson["query"]["categorymembers"]:

# Get a token so that we're allowed to edit the page
tokenJson = getContent(editTokenPage % uriTitle, cookies).parseJson()
editToken = tokenJson["query"]["pages"].fields[0].val["edittoken"].str

editData = newMultipartData(
var editToken: string
for x in tokenJson["query"]["pages"].fields.values:
editToken = x["edittoken"].str
break


let editData = newMultipartData(
{"action": "edit", "format": "json", "summary": desc,
"title": uriTitle, "text": newText, "token": editToken})

Expand Down
2 changes: 1 addition & 1 deletion reversalgame.nim
@@ -1,4 +1,4 @@
import math, rdstdin, strutils, algorithm
import random, rdstdin, strutils, algorithm
randomize()

proc shuffle[T](x: var seq[T]) =
Expand Down
2 changes: 1 addition & 1 deletion shuffle.nim
@@ -1,4 +1,4 @@
import math
import random
randomize()

proc shuffle[T](x: var seq[T]) =
Expand Down
2 changes: 1 addition & 1 deletion statistics.nim
@@ -1,4 +1,4 @@
import math, strutils
import random, math, strutils
randomize()

proc sd(ns: openarray[float]): auto =
Expand Down
22 changes: 10 additions & 12 deletions test_all.nim
Expand Up @@ -31,7 +31,6 @@
## ./test_all wine nim -d:release c
##
## https://github.com/Araq/Nim/issues/1389
## https://github.com/Araq/Nim/issues/1888
##
## TODO:
## Javascript? node
Expand Down Expand Up @@ -75,18 +74,17 @@ proc returns(name: string; compParams = ""; params = ""; input = ""): bool =
echo "Interrupted"
return p.outputStream.readStr(100000) == readFile(name & ".out")
else:
if not existsFile(name & ".out"):
return execProcess("./" & name & " " & params) == ""
var p: Process
if "wine " in compCommand or "mingw" in compCommand:
p = startProcess("/usr/bin/wine", args = @[name & ".exe"] & params.split)
else:
var p: Process
if "wine " in compCommand or "mingw" in compCommand:
p = startProcess("/usr/bin/wine", args = @[name & ".exe"] & params.split)
else:
p = startProcess(name, args = params.split)
p.inputStream.write(input)
p.inputStream.close()
if p.waitForExit > 0: return false
return closeEnough(p.outputStream.readStr(100000), readFile(name & ".out"))
p = startProcess(name, args = params.split)
p.inputStream.write(input)
p.inputStream.close()
if p.waitForExit > 0: return false
if not existsFile(name & ".out"):
return p.outputStream.readStr(100000) == ""
return closeEnough(p.outputStream.readStr(100000), readFile(name & ".out"))

template testIt(name: string, rest: stmt): stmt {.immediate.} =
test name:
Expand Down
2 changes: 1 addition & 1 deletion unbiasrandom.nim
@@ -1,4 +1,4 @@
import math, strutils
import random, strutils
randomize()

template newSeqWith(len: int, init: expr): expr =
Expand Down
2 changes: 1 addition & 1 deletion zeropowzero.nim
@@ -1,3 +1,3 @@
import math

echo pow(0, 0)
echo pow(0.0, 0.0)

0 comments on commit b6a2d3c

Please sign in to comment.