Memoize

BasicWerk   EC Support   Technique   Facebook  

20140605090244_zsh_array

zsh で配列に push

 

#! /bin/zsh
 
# 配列として宣言
typeset -a foo
 
# foo を set -A で置き換える
# = push
for elt in foo bar baz
do
    set -A foo $foo[@] $elt
done
 
echo ${(qqq)foo[@]}
# -> "foo" "bar" "baz"

© Shin Nakamura/BasicWerk 2014