Ticket #21 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

Add another form of unfoldr

Reported by: Khudyakov Owned by:
Priority: major Milestone: 0.8
Version: 0.7 Keywords:
Cc: alexey.skladnoy@…

Description

Please add following functions for construction of immutable vectors. They are useful for generation of n first element like power series, sequence defined as recurrent relation etc.

iterate :: Int -> (a -> a) -> a -> Vector a

-- I can't think of nice name (unfoldrN is taken already)
unfoldrN2 :: Int -> (b -> (a,b)) -> b -> Vector a

Clearly they are specializations of unfoldr. I think they are quite useful especially first one. Second function could be easily defined in terms of unfoldrN but it should be advantageous from perfomance point of view. There is no need to wrap/unwrap value to/from Maybe.

Attachments

vector-iterate.dpatch (8.1 kB) - added by Khudyakov 2 years ago.

Change History

Changed 3 years ago by rl

  • milestone set to 0.7

Changed 3 years ago by rl

  • priority changed from minor to major

Changed 3 years ago by rl

  • version set to 0.7
  • milestone changed from 0.7 to 0.8

Changed 3 years ago by Khudyakov

I have incomplete patch for iterate function. I hope i will finish it a week or so.

Changed 2 years ago by Khudyakov

Changed 2 years ago by Khudyakov

Well, week could be a really long time. Here is patch for iterate. It looks like it does work as expected.

Changed 2 years ago by rl

Applied, thanks. I renamed iterate to iterateN to be consistent with Data.Sequence and friends.

Changed 2 years ago by rl

  • summary changed from Add iterate and another form of unfoldr to Add another form of unfoldr

Changed 2 years ago by rl

  • status changed from new to closed
  • resolution set to fixed

Actually, since unfoldrN is inlined, there should be no performance difference between unfoldrN n . Just and unfoldrN2 n so I don't think it's necessary to add the latter. Please shout if you think otherwise!

Note: See TracTickets for help on using tickets.