BUCL.io / slice
Schneidet einen Teil aus einer Liste.
Beispiel
{res} slice 1 -1 "cut" "use" "cut"
Quellcode
#slice #description: Cut out a part of a list. #description-DE: Schneidet einen Teil aus einer Liste. #sample: {res} slice 1 -1 "cut" "use" "cut" #to test direct: {input} = 0 -1 "cut" "use" "cut" {start} = {input/0} {orgEnd} = {input/1} {end} math {input/1} + 2 {inputCount} count {input} {result} = "" {firstTakeItem} = 1 if {start} < 0 {start} math "{inputCount}{start}" if {start} < 2 {start} = 2 else {start} math {start} + 2 {loop} each {input} {takeItem} = 0 if {loop/index} >= {start} if {orgEnd} = 0 {takeItem} = 1 elseif {orgEnd} > 0 if {loop/index} < {end} {takeItem} = 1 elseif {orgEnd} < 0 {targetIndex} math {loop/length} {orgEnd} if {loop/index} < {targetIndex} {takeItem} = 1 if {takeItem} if {firstTakeItem} {firstTakeItem} = 0 {result} = {loop/value} else {result} = {result} {loop/value} {output} = {result}