my code of a hanoi game in haskell: module Hanoi where makeGame :: Int -> Int -> [[Int]] makeGame l _=[[]] makeGame x y = [[1..y] ]++ makeGame (x-1) 0 moveRing :: (([[Int]], Int, Int)->[[Int]]...


my code of a hanoi game in haskell:



module Hanoi

where



makeGame :: Int -> Int -> [[Int]]

makeGame l _=[[]]

makeGame x y = [[1..y] ]++ makeGame (x-1) 0



moveRing :: (([[Int]], Int, Int)->[[Int]]

moveRing (xs,y,z) = if (y

take (y-1) xs ++ [(tail (xs!!(y-1)))] ++dropy(take (z-1) xs)++ [(head (xs!!(y-1)) ):(xs!!(z-1))] ++dropzxs

else

take (z-1)xs++[(head (xs!!(y-1)) ) :(xs!!(z-1))]++dropz(take (y-1) xs)++[tail (xs!!(y-1))]++dropyxs



approvedMove :: ([[Int]],Int,Int)-> Bool

approvedMove (xs,y,z) = if (y>length xs ||z>length xs) thenFalse

else

if (xs!!(y-1[] then False

else

if (xs!!(z-1))==[] then True

else

ifhead(xs!!(y-1))< head="" (xs!!(z-1))="">

elseFalse



startGame :: IO [[Int]]

startGame = do

putstrLn("Let's play tower of Hanoi. Write the number of towers:")

x<>

putstrLn("Write numbers of rings:")

y<>

putstrLn("you choosed "++ x ++"towers and "++ y ++" rings")

putstrLn("starting game")

return (makeGame (read x::Int) (read y::Int))



playingGame :: [[Int]]->IO [[Int]]

playingGame xss= if (all null (init xss)) then

do

showHanoixss

putstrLn("you won")

returnxss

else

do

showHanoixss

putstrLn("enter the stick you want to move from:")

x<>

putstrLn("enter stick to move to:")

y<>

and the error i need help to fix is in the picture

Hanoi.hs:9:1: error:<br>parse error (possibly incorrect indentation or mismatched brackets)<br>9 | moveRing (xs,y,z)<br>= if (y<z) then<br>Failed, no modules loaded.<br>

Extracted text: Hanoi.hs:9:1: error: parse error (possibly incorrect indentation or mismatched brackets) 9 | moveRing (xs,y,z) = if (y
module Hanọi<br>where<br>makeGame :: Int -> Int -> [[Int]]<br>makeGame l _=[[]]<br>makeGame x y =<br>[[1..y] ]++ makeGame (x-1) 0<br>moveRing :: (([[Int]], Int, Int)->[[Int]]<br>moveRing (xs,y,z)<br>= if (y<z) then<br>take (y-1) xs ++ [(tail (xs !!(y-1)))] ++drop y(take (z-1) xs)++ [(head (xs!!(y-1)) ):(xs!!(z-1))] ++drop z xs<br>else<br>take (z-1)xs++[(head (xs!!(y-1)) ) :(xs!!(z-1))]++drop z(take (y-1) xs)++[tail (xs!!(y-1))]++drop y xs<br>approvedMove :: ([[Int]],Int,Int)-> Bool<br>approvedMove (xs,y,z) = if (y>length xs ||z>length xs) then False<br>%3D<br>else<br>if (xs!!(y-1[] then False<br>else<br>if (xs!!(z-1))==[] then True<br>else<br>if head(xs!!(y-1))< head (xs!!(z-1)) then True<br>else False<br>startGame :: I0 [[Int]]<br>startGame = do<br>putstrLn(

Extracted text: module Hanọi where makeGame :: Int -> Int -> [[Int]] makeGame l _=[[]] makeGame x y = [[1..y] ]++ makeGame (x-1) 0 moveRing :: (([[Int]], Int, Int)->[[Int]] moveRing (xs,y,z) = if (y Bool approvedMove (xs,y,z) = if (y>length xs ||z>length xs) then False %3D else if (xs!!(y-1[] then False else if (xs!!(z-1))==[] then True else if head(xs!!(y-1))< head="" (xs!!(z-1))="" then="" true="" else="" false="" startgame="" ::="" i0="" [[int]]="" startgame="do" putstrln("let's="" play="" tower="" of="" hanoi.="" write="" the="" number="" of="" towers:")=""><-getline>
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here