loop through the list...

2003-08-14 Thread Fredrik Petersson
hi again... :)

Ok assume i got this list of tuples [(10,1),(20,2),(30,3)]
where i in (i,j) is a index,
i want to go through the list and add a number witch matches the best index.
Like 18 should give me [(10,1),(20,3),(30,3)] since 18 are over 10 and under
20... aky?

something like [if (thenumber  index) then (index,int+1) \and break\ else
(index,int) | (index,int) - [thelist]]
My problem is that i dont know how to do the break thing! next time the
value gonna be smaller than the 30 and ++ the int.
Can i use some help-boolean to set it false when we have counted up once?
and include that one in the if-stmt?? How do i do that?

I guess your laughing your pants wet right now coz there are of-corz some
smart built-in functions in haskell to do this kind of silly ting, so please
tell me! :)

Respect the rock!
//Fredde

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: loop through the list...

2003-08-11 Thread Ketil Z. Malde
Fredrik Petersson [EMAIL PROTECTED] writes:

 something like [if (thenumber  index) then (index,int+1) \and break\ else
 (index,int) | (index,int) - [thelist]]

I think you need to write an explicit recursion, instead of using a
list comprehension. 

 Can i use some help-boolean to set it false when we have counted up once?

Using a fold(r|l) would be similar, but I think you'd be better
advised at this point to write the recursion explicitly.

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


SV: loop through the list...

2003-08-11 Thread Fredrik Petersson
Sure it is!
Our book sux, and a hate sitting for hour after hour with the same sucking
problem.
Sometimes you need a hint to get on...

Like I think you need to write an explicit recursion are a nice hits which
i guess would lead me to the right path again.

//FRedde

-Ursprungligt meddelande-
Från: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Lennart Augustsson
Skickat: den 11 augusti 2003 01:03
Till: Fredrik Petersson
Kopia: [EMAIL PROTECTED]
Ämne: Re: loop through the list...


This really sounds a lot like home work. :)

-- Lennart

Fredrik Petersson wrote:

hi again... :)

Ok assume i got this list of tuples [(10,1),(20,2),(30,3)]
where i in (i,j) is a index,
i want to go through the list and add a number witch matches the best
index.
Like 18 should give me [(10,1),(20,3),(30,3)] since 18 are over 10 and
under
20... aky?

something like [if (thenumber  index) then (index,int+1) \and break\ else
(index,int) | (index,int) - [thelist]]
My problem is that i dont know how to do the break thing! next time the
value gonna be smaller than the 30 and ++ the int.
Can i use some help-boolean to set it false when we have counted up once?
and include that one in the if-stmt?? How do i do that?

I guess your laughing your pants wet right now coz there are of-corz some
smart built-in functions in haskell to do this kind of silly ting, so
please
tell me! :)

Respect the rock!
//Fredde

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell





___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: loop through the list...

2003-08-10 Thread Lennart Augustsson
This really sounds a lot like home work. :)

   -- Lennart

Fredrik Petersson wrote:

hi again... :)

Ok assume i got this list of tuples [(10,1),(20,2),(30,3)]
where i in (i,j) is a index,
i want to go through the list and add a number witch matches the best index.
Like 18 should give me [(10,1),(20,3),(30,3)] since 18 are over 10 and under
20... aky?
something like [if (thenumber  index) then (index,int+1) \and break\ else
(index,int) | (index,int) - [thelist]]
My problem is that i dont know how to do the break thing! next time the
value gonna be smaller than the 30 and ++ the int.
Can i use some help-boolean to set it false when we have counted up once?
and include that one in the if-stmt?? How do i do that?
I guess your laughing your pants wet right now coz there are of-corz some
smart built-in functions in haskell to do this kind of silly ting, so please
tell me! :)
Respect the rock!
//Fredde
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell
 



___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell