simple mysum predicate
viral2_at_hotmail.com
Date: 12/05/03
- Next message: Pento: "Re: simple mysum predicate"
- Previous message: Jan Wielemaker: "Re: draw icon"
- Next in thread: Pento: "Re: simple mysum predicate"
- Reply: Pento: "Re: simple mysum predicate"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 4 Dec 2003 16:42:35 -0800
if i want to return a sublist of numbers that equal a given number
from an original list mysum(numlist,sum,subsum) is the best way to go
about it:
1)add up all the numbers in current list
2)then sum th total with the head of the list of #'s
3)if it is equal to the desired sum,stop.
4)else if it is less than the desired sum, add it to the list and move
on to the next number.
5)else its greater than the sum,skip it and move on tho the next
number.
i.e. mysum([1,2,5,3,2],5,NN). will return all the sublist(s) that add
up to 5.
- Next message: Pento: "Re: simple mysum predicate"
- Previous message: Jan Wielemaker: "Re: draw icon"
- Next in thread: Pento: "Re: simple mysum predicate"
- Reply: Pento: "Re: simple mysum predicate"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]