Commits

committed 9c869c2

properly round

• Participants
• Parent commits 85d252e
• Branches benchmarks

File crypt.pl

` sum2([A | AL], [B | BL], Carry, [C | CL]) :- !,`
` 	X is (A + B + Carry),`
` 	C is X mod 10,`
`-	NewCarry is X // 10,`
`+	NewCarry is floor(X / 10),`
` 	sum2(AL, BL, NewCarry, CL).`
` sum2([], BL, 0, BL) :- !.`
` sum2(AL, [], 0, AL) :- !.`
` sum2([], [B | BL], Carry, [C | CL]) :- !,`
` 	X is B + Carry,`
`-	NewCarry is X // 10,`
`+	NewCarry is floor(X / 10),`
` 	C is X mod 10,`
` 	sum2([], BL, NewCarry, CL).`
` sum2([A | AL], [], Carry, [C | CL]) :- !,`
` 	X is A + Carry,`
`-	NewCarry is X // 10,`
`+	NewCarry is floor(X / 10),`
` 	C is X mod 10,`
` 	sum2([], AL, NewCarry, CL).`
` sum2([], [], Carry, [Carry]).`
` `
` mult([], _, Carry, [C, Cend]) :-`
` 	C is Carry mod 10,`
`-	Cend is Carry // 10.`
`+	Cend is floor(Carry / 10).`
` mult([A | AL], D, Carry, [B | BL] ) :-`
` 	X is A * D + Carry,`
` 	B is X mod 10,`
`-	NewCarry is X // 10,`
`+	NewCarry is floor(X / 10),`
` 	mult(AL, D, NewCarry, BL).`
` `
` zero([]).`