I have a function onemove that I am recursively calling upon a list moves. The function onemove returns a 3-tuple (Int,[Char],[[Char]]), namely time, captures, and board . I would like to call the function onemove on the input tuple for each move in the moves list. Below I have provided my code thus far:
makemoves :: (Int,[Char],[[Char]],[(Int,Int)]) -> (Int,[Char],[[Char]])
makemoves (time, captures, board, [] ) = (time, captures, board)
makemoves (time, captures, board, (moveFrom, moveTo):moves )
| checkerAlive board = makemoves (onemove (time, captures, board, move:moves))
| otherwise = resetGame (time, captures, board)
where copyTime = time
copyCaptures = captures
copyBoard = board
move = (moveFrom,moveTo)
tempTuple = onemoving (time, captures, board, move)
How might I call the function makemoves recursively? onemovereturns a 3-tuple, while makemoves is expecting a 4-tuple, which is the returned 3-tuple plus the next move. Thanks!
onemovethe same asmakemoves?copyBoard = board? Also instead of definingmovein thewhereclause you can use@patterns:move@(moveFrom, moveTo):moves. Regarding your problem, there are some circumstances where it's easier to write a helper function that returns redundant information and write the actual function by calling it and dropping the not-needed information. Lazyness will also avoid to actually compute information that isn't really required.