Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Nim

Visibility

unlisted

Author

legacy-anonymous

Created

2016-08-14T18:20:12Z

Updated

2016-08-14T18:20:12Z

import strutils
 
const text = ["---------- Ice and Fire ------------",
"fire, in end will world the say Some",
"ice. in say Some",
"desire of tasted I've what From",
"fire. favor who those with hold I",
"",
"... elided paragraph last ...",
"",
"Frost Robert -----------------------"]
 
proc reversed*[T](a: openArray[T], first, last: int): seq[T] =
  result = newSeq[T](last - first + 1)
  var x = first
  var y = last
  while x <= last:
    result[x] = a[y]
    dec(y)
    inc(x)
 
proc reversed*[T](a: openArray[T]): seq[T] =
  reversed(a, 0, a.high)
 
var foo: string
for i in 0..1000:
  for line in text:
    if len(line) == 0:
      foo = ""
      continue
    # Count up the tokens
    var tCount = 0
    for llen in 0..line.high:
      if line[llen] == ' ':
        tCount += 1
    var next = newSeq[string](tCount+1)
    let words = line.split(' ')
    for j in 0..tCount:
      next[j] = words[tCount-j]
    let foo = next.join(" ")
    # echo foo
echo(foo)
INFO