私は mozart oz が初めてで、この問題を解決する必要があります。
a) Implement a function Zip that takes a pair Xs#Ys of two lists Xs and Ys (of the
same length) and returns a pairlist, where the first field of each pair is taken
from Xs and the second from Ys. For example, {Zip [a b c]#[1 2 3]} returns the
pairlist [a#1 b#2 c#3].
b) The function UnZip does the inverse, for example {UnZip [a#1 b#2 c#3]}
returns [a b c]#[1 2 3]. Give a specification and implementation of UnZip.
私が知っている#
のは、ドキュメントから取得した、ペア/タプルを構成するある種のラベルであるということだけですが、それを操作する方法を示す例が見つかりませんでした。
私の質問は、それを分割してアイテムを取得する方法、またはそのラベルを操作する方法 (または、操作方法の例があるソース) です。
少し検索して、このコードにたどり着きました(構文的に正しいかどうかはわかりません):
declare
fun {Zip L}
case L of nil then nil
[] L1#L2 then .... % Here i'm stuck or i don't know how to proceed
end
end
{Browse {Zip ['a' 'b' 'c']#[1 2 3]}}
どんな助けでも大歓迎です。
御時間ありがとうございます。