它编译正确,但不起作用。
它适用于[]
但如果它有其他任何东西,它就会永远挂起。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)