## Tcl9.0.3/Tk9.0.3 Documentation > Tcl Commands > lpop

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

### NAME

lpop — リスト内の要素を取得し削除する Get and remove an element in a list

### 構文 SYNOPSIS

lpop varName ?index ...?

### 説明 DESCRIPTION

lpop 命令は､Tcl リストを含んでいる変数の名前として解釈する假引数 varName を受容れる｡それは一つ或はリスト内にそれ以上の索引位置も受容れる｡ もし､索引がないと､それは無為設定では "end" となる｡ The lpop command accepts a parameter, varName, which it interprets as the name of a variable containing a Tcl list. It also accepts one or more indices into the list. If no indices are presented, it defaults to "end".

一つの索引を伴って与えられた時､lpop 命令はその中のindex 番目の要素に取掛かり､リストからそれを削除しその要素を返す｡(訳註:if->it) 　 When presented with a single index, the lpop command addresses the index'th element in it, removes if from the list and returns the element.

もし index が負数か､ 呼ばれた変数varName内のリスト内の要素の個数と等しいかより大きいと､ 不都合が生じる｡ If index is negative or greater or equal than the number of elements in the list in the variable called varName, an error occurs.

それぞれの単純な index 値の解釈は､単純な算術索引とリストの末尾への相対索引を運営している string index 命令と同じである｡ The interpretation of each simple index value is the same as for the command string index, supporting simple index arithmetic and indices relative to the end of the list.

もし､追加の index引数が供給されると､ それぞれの引数は､順番に､以前の索引操作によって指定された 副リスト内部の要素に取掛かる事に使われて､記述譜に､ 副リスト内の要素を取除く事を許容し､ lindex や lsetに似ている｡ If additional index arguments are supplied, then each argument is used in turn to address an element within a sublist designated by the previous indexing operation, allowing the script to remove elements in sublists, similar to lindex and lset. The command,

    lpop a 1 2

部部リスト 1 の要素2を得て除去する｡ gets and removes element 2 of sublist 1.

### EXAMPLES

これらの用例のそれぞれでの x の初期値は: In each of these examples, the initial value of x is:

    set x [list [list a b c] [list d e f] [list g h i]]
          → {a b c} {d e f} {g h i}

指し示された値はx の新しい値になる(但し､最後の場合は､不都合になり､x の値は変更されず残る｡) The indicated value becomes the new value of x (except in the last case, which is an error which leaves the value of x unchanged.)

    lpop x 0
          → {d e f} {g h i}
    lpop x 2
          → {a b c} {d e f}
    lpop x end
          → {a b c} {d e f}
    lpop x end-1
          → {a b c} {g h i}
    lpop x 2 1
          → {a b c} {d e f} {g i}
    lpop x 2 3 j
          → list index out of range

次の用例では､ x の初期値は: 　 In the following examples, the initial value of x is:

    set x [list [list [list a b] [list c d]] \
                [list [list e f] [list g h]]]
          → {{a b} {c d}} {{e f} {g h}}

指し示された値は､ x の新しい値になる｡ The indicated value becomes the new value of x.

    lpop x 1 1 0
          → {{a b} {c d}} {{e f} h}

### SEE ALSO

list, lappend, lassign, ledit, lindex, linsert, llength, lmap, lrange, lremove, lrepeat, lreplace, lreverse, lsearch, lseq, lset, lsort, string

### KEYWORDS

element, index, list, remove, pop, stack, queue
Copyright © 2018 Peter Spjuth. All rights reserved.