Earlier quoted context omitted.
I have been meaning to explore Nim for a while because it feels like "golang, but python syntax and dev experience." I vibe coded a simple tool, tt, that allows me to track time to a central log from all my devices. Realllly simple: $ tt stats Time Tracking Stats Total entries: 39 First entry: Oct 21, 2025 23:04 Last entry: Oct 30, 2025 18:29 Tracking since: 228h 34m Days tracked: 5 $ tt "working on xyz today" Logged…
What are the `@` characters for? Are they what makes it feel like Perl? Because other than them I don’t think the equivalent Python code would look much different. Maybe more concise, e.g. you could replace the second section with something like `sorted = entries.sorted(key=lambda entry: entry.timestamp)`.
let sorted = entries.sorted(proc (a, b: Entry): int = cmp(a.timestamp, b.timestamp))
let sorted = entries.sorted((a, b) => cmp(a.timestamp, b.timestamp))
let sorted = entries.sortedByIt(it.timestamp)
I suppose you could change the whole proc to something like proc groupIntoThreads(entries: seq[Entry], threshold: int): seq[seq[Entry]] =
let sorted = entries.sortedByIt(it.timestamp)
for i, entry in sorted:
if i == 0 or entry.timestamp - sorted[i - 1].timestamp > threshold:
result.add(@[sorted[i]])
else:
result[^1].add(sorted[i])