正しくコンパイルされますが、動作しません。
それは機能し[]
ますが、それ以外の場合は永遠にハングアップします。test1
- わかりました、test 2
ハングします。
--Tests pour 'effectuerAchat'.
test1 = effectuerAchat achat1_1 [] == ([],achat1_1)
test2 = effectuerAchat achat1_1 [offre1_1_1_100] == ([(Commande "fournisseur1" "article1" 1 100)],Achat "article1" 0)
ここにコードがあります...
effectuerAchat a os = rfred a (offresPour a os) (achatQuantite(a)) []
where rfred a os n lc =
if os == []|| n==0
then (lc,(Achat (achatArticle(a)) n))
else
if n>=(offreQuantite(head(os)))
then let c= (Commande (offreFournisseur(head(os))) (achatArticle(a)) (offreQuantite(head(os))) (offrePrix(head(os))))
n= n-(offreQuantite(head(os)))
xs = tail(os)
in rfred a xs n (c:lc)
else let c= (Commande (offreFournisseur(head(os))) (achatArticle(a)) n (offrePrix(head(os))))
n= 0
xs = tail(os)
in rfred a xs n (c:lc)