mirror of
https://github.com/ganelson/inform.git
synced 2024-07-03 07:24:58 +03:00
initial commit
This commit is contained in:
parent
d2fd3edeec
commit
08cf263724
56
inform7/Tests/Test Cases/ListBasicsPrepositions.txt
Normal file
56
inform7/Tests/Test Cases/ListBasicsPrepositions.txt
Normal file
|
@ -0,0 +1,56 @@
|
|||
The Brahms Conservatoire is a room.
|
||||
|
||||
When play begins:
|
||||
let L be a list of numbers;
|
||||
say "L is initially [L in brace notation].";
|
||||
add 11 to L;
|
||||
say "L is now [L in brace notation].";
|
||||
add 7 to L;
|
||||
add 200 to L;
|
||||
add 5 to L;
|
||||
add -6 to L;
|
||||
add 0 to L;
|
||||
say "L is now [L in brace notation].";
|
||||
add 5 to L, if absent;
|
||||
say "Adding 5 if absent should make no difference: [L in brace notation].";
|
||||
reverse L;
|
||||
say "L reverses to [L in brace notation].";
|
||||
sort L;
|
||||
say "L sorts to [L in brace notation].";
|
||||
reverse L;
|
||||
say "L then reverses to [L in brace notation].";
|
||||
say "Entry 2 of L is [entry 2 of L].";
|
||||
now entry 3 of L is 104;
|
||||
say "After changing entry 3 to 104, L is now [L in brace notation].";
|
||||
now entry 3 of L is 208;
|
||||
say "After changing entry 3 to 208, L is now [L in brace notation].";
|
||||
now entry 1 of L is 1;
|
||||
now entry 6 of L is 6;
|
||||
say "After changing the two end entries, L is now [L in brace notation].";
|
||||
say "These, however, should fail as being out of range.";
|
||||
now entry 0 of L is 104;
|
||||
now entry 7 of L is 104;
|
||||
add 208 to L;
|
||||
say "L now contains two instances of 208: [L in brace notation].";
|
||||
remove 208 from L;
|
||||
say "Both of which go after removing this value: [L in brace notation].";
|
||||
let M be a list of numbers;
|
||||
add 2 to M; add 3 to M; add 5 to M; add 7 to M; add 11 to M;
|
||||
add M to L;
|
||||
say "Adding [M in brace notation] to L gives [L in brace notation].";
|
||||
remove M from L;
|
||||
say "Removing the same set then gives [L in brace notation].";
|
||||
extend M to 5 entries;
|
||||
say "Extending M to 5 entries should not change it: [M in brace notation].";
|
||||
extend M to 7 entries;
|
||||
say "Extending M to 7 entries should add two 0s: [M in brace notation].";
|
||||
truncate M to 8 entries;
|
||||
say "Truncating M to 8 entries should make no difference: [M in brace notation].";
|
||||
truncate M to 4 entries;
|
||||
say "Truncating M to 4 entries should change it: [M in brace notation].";
|
||||
truncate M to the last 2 entries;
|
||||
say "Truncating M to the last 2 entries should certainly change it: [M in brace notation].";
|
||||
let N be a list of numbers;
|
||||
add 7 to N; add 11 to N; add 5 to N; add 16 to N;
|
||||
add N to M, if absent;
|
||||
say "Adding [N in brace notation] to M, if absent, gives [M in brace notation]."
|
17
inform7/Tests/Test Cases/TablePrepositions.txt
Normal file
17
inform7/Tests/Test Cases/TablePrepositions.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
The Plateau is a room.
|
||||
|
||||
Table of Fish
|
||||
fish-text fish-num
|
||||
"red snapper" 5
|
||||
"coelocanth" 17
|
||||
"neon tetra" 40
|
||||
|
||||
When play begins:
|
||||
say "[the fish-text corresponding to fish-num of 5 in Table of Fish].";
|
||||
say "[the fish-text corresponding to fish-num of 17 from Table of Fish].";
|
||||
say "[the fish-text corresponding to fish-num of 40 in Table of Fish].";
|
||||
say "[the fish-num in row 1 in the Table of Fish].";
|
||||
say "[the fish-num in row 2 from the Table of Fish].";
|
||||
say "[the fish-num in row 3 of the Table of Fish].";
|
||||
if there is a fish-text of "clownfish" in the Table of Fish, say "Who sent in the clowns?";
|
||||
if there is a fish-text of "neon tetra" from the Table of Fish, say "ore tenant.";
|
|
@ -0,0 +1,37 @@
|
|||
Brahms Conservatoire
|
||||
L is initially {}.
|
||||
L is now {11}.
|
||||
L is now {11, 7, 200, 5, -6, 0}.
|
||||
Adding 5 if absent should make no difference: {11, 7, 200, 5, -6, 0}.
|
||||
L reverses to {0, -6, 5, 200, 7, 11}.
|
||||
L sorts to {-6, 0, 5, 7, 11, 200}.
|
||||
L then reverses to {200, 11, 7, 5, 0, -6}.
|
||||
Entry 2 of L is 11.
|
||||
After changing entry 3 to 104, L is now {200, 11, 104, 5, 0, -6}.
|
||||
After changing entry 3 to 208, L is now {200, 11, 208, 5, 0, -6}.
|
||||
After changing the two end entries, L is now {1, 11, 208, 5, 0, 6}.
|
||||
These, however, should fail as being out of range.
|
||||
*** Couldn't write to list entry 0 of a list which has entries numbered from 1 to 6 ***
|
||||
|
||||
*** Run-time problem P50: Attempt to use list item which does not exist.
|
||||
|
||||
*** Couldn't write to list entry 7 of a list which has entries numbered from 1 to 6 ***
|
||||
L now contains two instances of 208: {1, 11, 208, 5, 0, 6, 208}.
|
||||
Both of which go after removing this value: {1, 11, 5, 0, 6}.
|
||||
Adding {2, 3, 5, 7, 11} to L gives {1, 11, 5, 0, 6, 2, 3, 5, 7, 11}.
|
||||
Removing the same set then gives {1, 0, 6}.
|
||||
Extending M to 5 entries should not change it: {2, 3, 5, 7, 11}.
|
||||
Extending M to 7 entries should add two 0s: {2, 3, 5, 7, 11, 0, 0}.
|
||||
Truncating M to 8 entries should make no difference: {2, 3, 5, 7, 11, 0, 0}.
|
||||
Truncating M to 4 entries should change it: {2, 3, 5, 7}.
|
||||
Truncating M to the last 2 entries should certainly change it: {5, 7}.
|
||||
Adding {7, 11, 5, 16} to M, if absent, gives {5, 7, 11, 16}.
|
||||
|
||||
Welcome
|
||||
An Interactive Fiction
|
||||
Release 1 / Serial number 150512 / Inform 7 build 6M22 (I6/v6.33 lib 6/12N) SD
|
||||
|
||||
Brahms Conservatoire
|
||||
|
||||
> > Brahms Conservatoire
|
||||
> Are you sure you want to quit?
|
|
@ -0,0 +1,19 @@
|
|||
Plateau
|
||||
red snapper.
|
||||
coelocanth.
|
||||
neon tetra.
|
||||
5.
|
||||
17.
|
||||
40.
|
||||
ore tenant.
|
||||
|
||||
Welcome
|
||||
An Interactive Fiction
|
||||
Release 1 / Serial number 220625 / Inform 7 v10.1.0 / D
|
||||
|
||||
Plateau
|
||||
> > Plateau
|
||||
> Are you sure you want to quit?
|
||||
|
||||
|
||||
|
|
@ -1290,7 +1290,7 @@ To add (new entry - K) to (L - list of values of kind K), if absent
|
|||
(documented at ph_addtolist):
|
||||
(- LIST_OF_TY_InsertItem({-lvalue-by-reference:L}, {new entry}, 0, 0, {phrase options}); -).
|
||||
|
||||
To add (new entry - K) at entry (E - number) in (L - list of values of kind K), if absent
|
||||
To add (new entry - K) at entry (E - number) in/from (L - list of values of kind K), if absent
|
||||
(documented at ph_addatentry):
|
||||
(- LIST_OF_TY_InsertItem({-lvalue-by-reference:L}, {new entry}, 1, {E}, {phrase options}); -).
|
||||
|
||||
|
@ -1298,23 +1298,23 @@ To add (LX - list of Ks) to (L - list of values of kind K), if absent
|
|||
(documented at ph_addlisttolist):
|
||||
(- LIST_OF_TY_AppendList({-lvalue-by-reference:L}, {-by-reference:LX}, 0, 0, {phrase options}); -).
|
||||
|
||||
To add (LX - list of Ks) at entry (E - number) in (L - list of values of kind K)
|
||||
To add (LX - list of Ks) at entry (E - number) in/from (L - list of values of kind K)
|
||||
(documented at ph_addlistatentry):
|
||||
(- LIST_OF_TY_AppendList({-lvalue-by-reference:L}, {-by-reference:LX}, 1, {E}, 0); -).
|
||||
|
||||
To remove (existing entry - K) from (L - list of values of kind K), if present
|
||||
To remove (existing entry - K) in/from (L - list of values of kind K), if present
|
||||
(documented at ph_remfromlist):
|
||||
(- LIST_OF_TY_RemoveValue({-lvalue-by-reference:L}, {existing entry}, {phrase options}); -).
|
||||
|
||||
To remove (N - list of Ks) from (L - list of values of kind K), if present
|
||||
To remove (N - list of Ks) in/from (L - list of values of kind K), if present
|
||||
(documented at ph_remlistfromlist):
|
||||
(- LIST_OF_TY_Remove_List({-lvalue-by-reference:L}, {-by-reference:N}, {phrase options}); -).
|
||||
|
||||
To remove entry (N - number) from (L - list of values), if present
|
||||
To remove entry (N - number) in/from (L - list of values), if present
|
||||
(documented at ph_rementry):
|
||||
(- LIST_OF_TY_RemoveItemRange({-lvalue-by-reference:L}, {N}, {N}, {phrase options}); -).
|
||||
|
||||
To remove entries (N - number) to (N2 - number) from (L - list of values), if present
|
||||
To remove entries (N - number) to (N2 - number) in/from (L - list of values), if present
|
||||
(documented at ph_rementries):
|
||||
(- LIST_OF_TY_RemoveItemRange({-lvalue-by-reference:L}, {N}, {N2}, {phrase options}); -).
|
||||
|
||||
|
@ -1347,7 +1347,7 @@ See test case |BIP-ListLength|.
|
|||
=
|
||||
Section 4 - Length of lists
|
||||
|
||||
To decide what number is the number of entries in/of (L - a list of values)
|
||||
To decide what number is the number of entries in/of/from (L - a list of values)
|
||||
(documented at ph_numberentries):
|
||||
(- LIST_OF_TY_GetLength({-by-reference:L}) -).
|
||||
To truncate (L - a list of values) to (N - a number) entries/entry
|
||||
|
|
|
@ -442,10 +442,10 @@ Again, this is part of a condition, and can't evaluate.
|
|||
=
|
||||
<s-table-reference> ::=
|
||||
<s-table-column-name> entry | ==> @<Table (a)@>
|
||||
<s-table-column-name> in row <s-value-uncached> of <s-value-uncached> | ==> @<Table (b)@>
|
||||
<s-table-column-name> in row <s-value-uncached> in/of/from <s-value-uncached> | ==> @<Table (b)@>
|
||||
<s-table-column-name> listed in <s-value-uncached> | ==> @<Table (c)@>
|
||||
<s-table-column-name> corresponding to <s-table-column-name> of <s-value-uncached> in <s-value-uncached> | ==> @<Table (d)@>
|
||||
<s-table-column-name> of <s-value-uncached> in <s-value-uncached> ==> @<Table (e)@>
|
||||
<s-table-column-name> corresponding to <s-table-column-name> of <s-value-uncached> in/from <s-value-uncached> | ==> @<Table (d)@>
|
||||
<s-table-column-name> of <s-value-uncached> in/from <s-value-uncached> ==> @<Table (e)@>
|
||||
|
||||
@<Table (a)@> =
|
||||
parse_node *spec = Lvalues::new_TABLE_ENTRY(W);
|
||||
|
|
|
@ -14683,7 +14683,7 @@ results in L being {2, 3, 5, 7, 11, 13, 17, 19}.
|
|||
|
||||
If we don't want to add new entries at the end, we can instead say where they should go:
|
||||
|
||||
{defn ph_addatentry}add (value) at entry (number) in (list of values)
|
||||
{defn ph_addatentry}add (value) at entry (number) in/from (list of values)
|
||||
This phrase adds the given value so that it becomes the entry with that index number in the list. Example:
|
||||
|
||||
let L be {1, 2, 3, 4, 8, 24};
|
||||
|
@ -14692,7 +14692,7 @@ This phrase adds the given value so that it becomes the entry with that index nu
|
|||
sets L to {1, 2, 3, 4, 8, 12, 24}. If there are N entries in L, then we can add at any of entries 1 up to N+1: adding at entry N+1 means adding at the end. The phrase option "if absent" makes the phrase do nothing if the value already exists anywhere in L.
|
||||
{end}
|
||||
|
||||
{defn ph_addlistatentry}add (list of values) at entry (number) in (list of values)
|
||||
{defn ph_addlistatentry}add (list of values) at entry (number) in/from (list of values)
|
||||
This phrase adds the first list to the second so that it begins at the given position. Example:
|
||||
|
||||
let L be {1, 2, 3, 4};
|
||||
|
@ -14713,7 +14713,7 @@ even though L and M have the same values, repeated the same number of times - fo
|
|||
|
||||
We can also strike out values:
|
||||
|
||||
{defn ph_remfromlist}remove (value) from (list of values)
|
||||
{defn ph_remfromlist}remove (value) in/from (list of values)
|
||||
This phrase removes every instance of the given value from the list. Example:
|
||||
|
||||
let L be {3, 1, 4, 1, 5, 9, 2, 6, 5, 3};
|
||||
|
@ -14722,7 +14722,7 @@ This phrase removes every instance of the given value from the list. Example:
|
|||
results in L being {3, 4, 5, 9, 2, 6, 5, 3}. Ordinarily "remove 7 from L" would produce a run-time problem, since L does not contain the value 7, but using the "if present" option lets us off this: the phrase then does nothing if L does not contain the value to be removed.
|
||||
{end}
|
||||
|
||||
{defn ph_remlistfromlist}remove (list of values) from (list of values)
|
||||
{defn ph_remlistfromlist}remove (list of values) in/from (list of values)
|
||||
This phrase removes every instance of any value in the first list from the second. Example:
|
||||
|
||||
let L be {3, 1, 4, 1, 5, 9, 2, 6, 5, 3};
|
||||
|
@ -14733,7 +14733,7 @@ results in L being {3, 1, 1, 5, 9, 5, 3}. If both lists are large, this can be a
|
|||
|
||||
Again, we can also remove from specific positions:
|
||||
|
||||
{defn ph_rementry}remove entry (number) from (list of values)
|
||||
{defn ph_rementry}remove entry (number) in/from (list of values)
|
||||
This phrase removes the entry at the given position, counting from 1 as the first entry. (Once it is removed, the other entries shuffle down.) Example:
|
||||
|
||||
let L be {3, 1, 4, 1, 5, 9, 2, 6, 5, 3};
|
||||
|
@ -14742,7 +14742,7 @@ This phrase removes the entry at the given position, counting from 1 as the firs
|
|||
results in L being {3, 1, 1, 5, 9, 2, 6, 5, 3}.
|
||||
{end}
|
||||
|
||||
{defn ph_rementries}remove entries (number) to (number) from (list of values)
|
||||
{defn ph_rementries}remove entries (number) to (number) in/from (list of values)
|
||||
This phrase removes the entries at the given range of positions, counting from 1 as the first entry. (Once they are removed, the other entries shuffle down.) Example:
|
||||
|
||||
let L be {3, 1, 4, 1, 5, 9, 2, 6, 5, 3};
|
||||
|
@ -14903,7 +14903,7 @@ results in L being { "heifer", "bullock", "cow"}. (This achieves the same effect
|
|||
|
||||
The length of a list can change as values are added or removed, and can in principle be any number from 0 upwards. A list with 0 entries is empty. We can find the length with:
|
||||
|
||||
{defn ph_numberentries}number of entries in/of (list of values) ... number
|
||||
{defn ph_numberentries}number of entries in/of/from (list of values) ... number
|
||||
This phrase produces the number of positions in the list. Example:
|
||||
|
||||
the number of entries in {1, 1, 1, 3, 1}
|
||||
|
|
Loading…
Reference in a new issue