Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 58f5ac7

Browse files
committed
Fixing dequeue RPOP bug
1 parent 7eb3376 commit 58f5ac7

File tree

1 file changed

+7
-7
lines changed
  • Classical/data-structures/dequeue/shell

1 file changed

+7
-7
lines changed

‎Classical/data-structures/dequeue/shell/dequeue.sh‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
items=()
44
while true ; do
5-
echo"... "
5+
printf"> "
66
read -r line
77
args=($line)
88
case ${args[0]} in
99
"FADD")
1010
arg_list=(${args[1]})
11-
arg_list+=${items[@]}
12-
items=$arg_list
11+
arg_list+=(${items[@]})
12+
items=(${arg_list[@]})
1313
;;
1414
"RADD")
1515
items+=(${args[1]})
1616
;;
1717
"FPOP")
1818
echo "${items[0]}"
19-
items=${items[@]:1}
19+
items=(${items[@]:1})
2020
;;
21-
"RPOP")
22-
echo "${items[-1]}"
23-
items=${items[@]:0:$((${#items[@]} - 1))}
21+
"RPOP")
22+
echo "${items[(( ${#items[@]} - 1))]}"
23+
items=(${items[@]:0:$((${#items[@]} - 1))})
2424
;;
2525
esac
2626

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /