Check-in [9cc9a92eab]

Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Updated lpop to not support index list.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9cc9a92eab40a3f53387eb34cb41db9c340879f2672ddb1325c9480a01285c6b
User & Date: pspjuth 2018-10-24 22:31:16.324
Context
2018-10-26
21:07
Started on discussion in 523 check-in: 9a80a7b5f2 user: pspjuth tags: trunk
2018-10-24
22:31
Updated lpop to not support index list. check-in: 9cc9a92eab user: pspjuth tags: trunk
19:36
Note the branch for TIP 520 check-in: f441fd78d3 user: dkf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/523.md.
35
36
37
38
39
40
41
42
43
44


45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64

	set stack [lrange [K $stack [set stack {}]] 0 end-1]

To support both queue and stack the pop end needs to be chosen, and the easiest
way is to have an index argument. This trivially extends the functionality to
remove any element.

Further, making it use index lists in the same way as lindex and lset does
gives more symmetry and together with lset's ability to add to a sublist,
doing push/pop on a sublist becomes feasible.



Since deleting last is rather common (stack) and also the cheapest operation,
that is selected as default when no index is given.

# Specification

A new command is added to the core with the following format.

	lpop listVar ?index ...?

The given index is resolved to an element in the same way as lindex/lset does.

The return value is the element at index, and the list is modified to
remove that element.
If no index is given, the default is "end".
An out of range index is an error.
If index is given as an empty list, that is an error.

# Copyright

This document has been placed in the public domain.







|


>
>










|
>




<




35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63
64
65
66

	set stack [lrange [K $stack [set stack {}]] 0 end-1]

To support both queue and stack the pop end needs to be chosen, and the easiest
way is to have an index argument. This trivially extends the functionality to
remove any element.

Further, making it use multiple indices in the same way as lindex and lset does
gives more symmetry and together with lset's ability to add to a sublist,
doing push/pop on a sublist becomes feasible.
The ability in lset and lindex to get an index list is not supported since
argument expansion covers that usage.

Since deleting last is rather common (stack) and also the cheapest operation,
that is selected as default when no index is given.

# Specification

A new command is added to the core with the following format.

	lpop listVar ?index ...?

The given indices are resolved to an element in the same way as lindex/lset
does, except an index list is not supported, just plain index arguments.
The return value is the element at index, and the list is modified to
remove that element.
If no index is given, the default is "end".
An out of range index is an error.


# Copyright

This document has been placed in the public domain.