Can we have any useful first order programs with infinite lists?

111 Views Asked by At

I am trying to come up with an example for infinite lists in a lazy first order language that i have implemented. I wanted to know if there are any useful programs which use infinite lists, but do not use any higher order functions.

1

There are 1 best solutions below

0
On

I used an infinite list to represent players in a game recently:

let playerList = [PlayerA, PlayerB]
let players = cycle playerList

let currentPlayer = head players
let advance = tail players -- "save" this to your players "variable"

-- or, maybe clearer, inside of MonadState [Player]
let advance' = modify tail

I think you could come up with a lot more.