var a = [
[
[1, 2, 3],
[4, 5, 6]
],
[
[7, 8, 9],
[10, 11]
], {
x: 12,
y: [13, 14, {
x: 15,
y: 16
}]
}
];
function iterate(e) {
if (typeof e == 'object') Object.keys(e).forEach(i => iterate(e[i]));
else console.log(e);
}
iterate(a);
#!/bin/bash
# conv.sh
if [[ ! -n $1 ]]; then
echo "output filename rquired"
exit 1
fi
TMP=$(mktemp -d)
i=0
while read FILE; do
NEW=${TMP}/${FILE%.*}.jpg
echo "${FILE} -> ${NEW}"
convert -quality 70 "${FILE}" "${NEW}"
a[i]="${NEW}"
((i++))
done
echo "converting ${#a[@]} files to $1"
convert "${a[@]}" "$1"
rm -r ${TMP}
<code>
Например: <code>ls -v1 *.png | ./conv.sh result.pdf</code>
function cycleClass(element, list, time) {
var i = -1;
var c = element.classList;
for (var n = 0; n < list.length; n++) {
if (c.contains(list[n])) {
if (i != -1) c.remove(list[i]);
i = n;
}
}
return setInterval(function () {
c.remove(list[i++]);
c.add(list[i %= list.length]);
}, time);
}
var a = 1, b = 1, f, sum = 0;
while ((f = a + b) < 4e6) {
a = b;
b = f;
if (!(f % 2)) sum += f;
}