Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のベクトルがあります。
t ← 1 2 2 3 4 5 5 5 6 6
そして、その各ペアを合計したいと思います( 2+/vec2つの隣接する要素ごとに合計する に似ています)。
2+/vec
APL でこれを行う最も効率的な方法は何ですか?
あなたの質問を理解できれば、2 つの項目ごとに合計しようとしています。これを行う最も簡単な方法は、行列に再形成してから行全体を合計することです。
t←1 2 2 3 4 5 5 5 6 6 5 2⍴t 1 2 2 3 4 5 5 5 6 6 +/5 2⍴t 3 5 9 10 12
これは、トリプレットなどに簡単に一般化できます。明らかに、結果の行列の形状を決定する小さな関数を書くことができます。