compute-constrained-bayes/jit_bayes.nim

36 lines
796 B
Nim
Raw Normal View History

2023-05-23 00:19:04 +00:00
import strutils
import sequtils
import bigints # type: BigInt
# let x = initBigInt("810896098877923596128062174904361421866219158")
let file_path = "./data/stripped"
proc startsWithSubsequence(xs: seq[string], ys: seq[string]): bool =
if xs.len == 0:
return true
elif ys.len == 0:
return false
elif xs[0] == ys[0]:
return startsWithSubsequence(xs[1..<xs.len], ys[1..<ys.len])
else:
return false
2023-05-23 00:19:04 +00:00
let f = open(file_path)
var line : string
2023-05-23 00:19:04 +00:00
var i = 0
var start = @["1", "2", "3"]
var seqs: seq[seq[string]]
2023-05-23 00:19:04 +00:00
while f.read_line(line):
if i > 3:
let seq = split(line, ",")
let l = seq.len
let nums = seq[1..(l-2)] # .map(proc (x: string): BigInt = initBigInt(x))
if startsWithSubsequence(start, nums):
seqs.add(nums)
2023-05-23 00:19:04 +00:00
i = i + 1
f.close()
echo seqs