在bash中,当我通过索引访问数组时,如果数组是在另一个bash脚本的源中导入的变量,则会出现奇怪的行为.是什么导致这种行为?怎样才可以固定而从另一个bash脚本源数组的行为方式从运行脚本中定义的数组一样吗?
$ {numbers [0]}躲避"一二三",而不是"一".我试图证明这种行为的完整测试如下所示:
test.sh的来源:
#!/bin/bash
function test {
echo "Length of array:"
echo ${#numbers[@]}
echo "Directly accessing array by index:"
echo ${numbers[0]}
echo ${numbers[1]}
echo ${numbers[2]}
echo "Accessing array by for in loop:"
for number in ${numbers[@]}
do
echo $number
done
echo "Accessing array by for loop with counter:"
for (( i = 0 ; i < ${#numbers[@]} ; i=$i+1 ));
do
echo $i
echo ${numbers[${i}]}
done
}
numbers=(one two three)
echo "Start test with array from within file:" …Run Code Online (Sandbox Code Playgroud) 在erlang中,我想格式化一个包含整数的字符串,我希望将结果展平.但我明白了:
io_lib:format("sdfsdf ~B", [12312]).
[115,100,102,115,100,102,32,"12312"]
Run Code Online (Sandbox Code Playgroud)
我可以通过使用下面的代码获得所需的结果,但它真的不优雅.
lists:flatten(io_lib:format("sdfsdf ~B", [12312])).
"sdfsdf 12312"
Run Code Online (Sandbox Code Playgroud)
是否有更好的格式化字符串,其中包含整数,以便它们是平的?理想情况下,只使用一个功能?
在emacs中使用自动完成扩展时如何保留大小写?
所以example不能完成Example或EXAMPLE.
我可以在运行时找到当前函数的名称吗?
foo() ->
foo = find_function_name().
Run Code Online (Sandbox Code Playgroud)
是否可以编写有趣的find_function_name/0?你会怎么做?它已经存在了吗?