-
1
- #1
Hi!
I want to remove elements in a list, that fulfill certain criteria. That is, in a list, I want to be able to remove all integers that are divisible by a given number N, which I like to give as input. In the example below N = 2.
listDivByN([1,2,3,4,5], 2, List).
should result in:
List = [1,3,5]
So far, I have managed to get a result like this: List = [1,0,1,0,1]. So my problem is that I can't remove the elements that are divisible by N. And 5 divsible with 2 shouldn't result in 1, because that is the remainder. It should result in 5.
Does anybody know how to do this ? I'm new to Prolog, and I would appreciate if someone could help me.
Thx!
I want to remove elements in a list, that fulfill certain criteria. That is, in a list, I want to be able to remove all integers that are divisible by a given number N, which I like to give as input. In the example below N = 2.
listDivByN([1,2,3,4,5], 2, List).
should result in:
List = [1,3,5]
So far, I have managed to get a result like this: List = [1,0,1,0,1]. So my problem is that I can't remove the elements that are divisible by N. And 5 divsible with 2 shouldn't result in 1, because that is the remainder. It should result in 5.
Does anybody know how to do this ? I'm new to Prolog, and I would appreciate if someone could help me.
Thx!