123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- discard """
- output: '''@[11, 12, 13]
- @[11, 12, 13]
- @[1, 3, 5]
- @[1, 3, 5]
- gppcbs
- gppcbs
- fpqeew
- fpqeew
- [11, 12, 13]
- [11, 12, 13]
- [11, 12, 13]
- [11, 12, 13]
- 11 12 13
- [11,12,13]
- <Students>
- <Student Name="Aprilfoo" />
- <Student Name="bar" />
- </Students>
- <chapter>
- <title>This is a Docbook title</title>
- <para>
- This is a Docbook paragraph containing <emphasis>emphasized</emphasis>,
- <literal>literal</literal> and <replaceable>replaceable</replaceable>
- text. Sometimes scrunched together like this:
- <literal>literal</literal><replaceable>replaceable</replaceable>
- and sometimes not:
- <literal>literal</literal> <replaceable>replaceable</replaceable>
- </para>
- </chapter>'''
- """
- block:
- var xs = @[1,2,3]
- for x in xs.mitems:
- x += 10
- echo xs
- block:
- var xs = [1,2,3]
- for x in xs.mitems:
- x += 10
- echo(@xs)
- block:
- var xs = @[1,2,3]
- for i, x in xs.mpairs:
- x += i
- echo xs
- block:
- var xs = [1,2,3]
- for i, x in xs.mpairs:
- x += i
- echo(@xs)
- block:
- var x = "foobar"
- for c in x.mitems:
- inc c
- echo x
- block:
- var x = "foobar"
- prepareMutation(x)
- var y = cast[cstring](addr x[0])
- for c in y.mitems:
- inc c
- echo x
- block:
- var x = "foobar"
- for i, c in x.mpairs:
- inc c, i
- echo x
- block:
- var x = "foobar"
- prepareMutation(x)
- var y = cast[cstring](addr x[0])
- for i, c in y.mpairs:
- inc c, i
- echo x
- import lists
- block:
- var sl = initSinglyLinkedList[int]()
- sl.prepend(3)
- sl.prepend(2)
- sl.prepend(1)
- for x in sl.mitems:
- x += 10
- echo sl
- block:
- var sl = initDoublyLinkedList[int]()
- sl.append(1)
- sl.append(2)
- sl.append(3)
- for x in sl.mitems:
- x += 10
- echo sl
- block:
- var sl = initDoublyLinkedRing[int]()
- sl.append(1)
- sl.append(2)
- sl.append(3)
- for x in sl.mitems:
- x += 10
- echo sl
- import deques
- block:
- var q = initDeque[int]()
- q.addLast(1)
- q.addLast(2)
- q.addLast(3)
- for x in q.mitems:
- x += 10
- echo q
- import json
- block:
- var j = parseJson """{"key1": 1, "key2": 2, "key3": 3}"""
- for key,val in j.pairs:
- val.num += 10
- echo j["key1"], " ", j["key2"], " ", j["key3"]
- block:
- var j = parseJson """[1, 2, 3]"""
- for x in j.mitems:
- x.num += 10
- echo j
- import xmltree, xmlparser, parsexml, streams, strtabs
- block:
- var d = parseXml(newStringStream """<Students>
- <Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
- <Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
- </Students>""")
- for x in d.mitems:
- x = <>Student(Name=x.attrs["Name"] & "foo")
- d[1].attrs["Name"] = "bar"
- echo d
- block:
- var d = parseXml(newStringStream """<chapter>
- <title>This is a Docbook title</title>
- <para>
- This is a Docbook paragraph containing <emphasis>emphasized</emphasis>,
- <literal>literal</literal> and <replaceable>replaceable</replaceable>
- text. Sometimes scrunched together like this:
- <literal>literal</literal><replaceable>replaceable</replaceable>
- and sometimes not:
- <literal>literal</literal> <replaceable>replaceable</replaceable>
- </para>
- </chapter>""",{reportComments, reportWhitespace})
- echo d
|