Skip to content

Instantly share code, notes, and snippets.

@ThePythonicCow
Created February 5, 2016 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThePythonicCow/23ef4a1a6a4620199a78 to your computer and use it in GitHub Desktop.
Save ThePythonicCow/23ef4a1a6a4620199a78 to your computer and use it in GitHub Desktop.
The following example, showing three commands (cat, nim c and nim -V) and their output,
run inside a terminal on my Debian Linux system, shows that the output of unindent does
not remove the two leading spaces from bar and baz, but rather removes zero spaces from
bar and one space from baz. (The "$" is my shell prompt, with a leading newline.)
The example comes from the Section 2.3.1 STRING of Dominik Picheta's "Nim in Action" book.
This is with the latest Nim Compiler Version 0.13.0. I saw the same, or similar, results
from an earlier 0.12.0 version.
=================== Begin terminal capture ===================
$ cat eg1.nim
import strutils
let multiLine = """foo
bar
baz
"""
echo multiLine.unindent
$ nim c -r eg1
Hint: system [Processing]
Hint: eg1 [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
CC: eg1
CC: stdlib_system
CC: stdlib_strutils
CC: stdlib_parseutils
Hint: [Link]
Hint: operation successful (12091 lines compiled; 0.538 sec total; 17.174MB; Debug Build) [SuccessX]
foo
bar
baz
$ nim -V
Nim Compiler Version 0.13.0 (2016-02-04) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf
git hash: a121c3f9eb2a348b9d6ae03ffd01aab26a238c30
active boot switches: -d:release
==================== End terminal capture ====================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment