I'm trying to solve a puzzle that uses a grid of data in Haskell...

I'm trying to solve a puzzle that uses a grid of data in Haskell. Why can't I use a good old for loop and change parts of the grid like grid[2][5] = 'Y'? I thought functional programming was supposed to be superior.

Attached: 903px-Haskell-Logo.svg.png (903x638, 15K)

Other urls found in this thread:

hackage.haskell.org/package/array-0.5.3.0/docs/Data-Array-ST.html
codewars.com/kata/4-by-4-skyscrapers
twitter.com/NSFWRedditVideo

It's superior for people with actual intelligence. Obviously you don't apply. Go back to JavaScript.

/thread

rekt

Learn what STU and forM_ are,

If you want something "similar" on the surface to a loop, use list comprehension. Otherwise recursion is your only choice. Remember functional programming is supposed to describe a program for what it is rather than creating it as a set of instructions, so you'll most likely have to rethink the whole thing.

just use STUArrays like the monkey you are:
hackage.haskell.org/package/array-0.5.3.0/docs/Data-Array-ST.html

>Nigger thinks programming languages should bend to his will because he's too retarded to learn

Loops are just syntactic sugar.
Anyway, your problem can easily be solved using nothing more than a map.

show your code and explain what you're trying to do
Depending on the type of the "grid' you're talking about and whether you're using monads or not it can be very different

z = [ [5, 5, 5], [6, 6, 6], [7, 7, 7] ]
coord = (1, 1)
newVal = 90

I want
f z coord newVal = [ [5, 5, 5], [6, 99, 6], [7, 7, 7] ]


I understand lists are linked lists and I probably shouldn't be using them in this manner. I will look into STUArrays

sorry I meant newVal = 99

>I understand lists are linked lists and I probably shouldn't be using them in this manner
Yes, that is correct. Why are you trying to destructively update a data structure in the first place? What are you trying to solve? If you are going to use haskell to program imperatively, you shouldn't bother learning it.

>Haskell
Haskell not for programming
Haskell for people who love to learn something

>*programs an os in it*
nothing personnel, kiddo

Attached: kaspersky-os-featured.jpg (1280x840, 274K)

Because that kind of update violates referential transparency. It's the price to pay for functional purity. You can still have some limited forms of destructive update without breaking referential transparency by using either the ST monad or the upcoming linear types, but you should only resort to ST if you have no other choice.

I'm trying to do this (For fun) in haskell codewars.com/kata/4-by-4-skyscrapers

programs and programed is different

based

Code like grid[2][5] = 'Y' can cause errors. Instead, try using a StateMonadTransformer prism. This lifts the state update to a functor over the algebra of StateMonad arrows. This is both safer and more readable.

I read this post in an autistic nasally voice

I ended up solving it without using monads. Just used simple recursion to make this function:

SHITING IN TOILET can cause PROBLEMS. Instead, try using a SHIT DESOLVE RITUAL. This lifts the state SHIT DESOLVING to a RITUAL SHIT KEEPER BY SHITING UP VERICALY TO THE TOP SHIT GATHERER. This is both safer and more readable.

>Just used simple recursion
it like counting from zero to 99 instead of direct acsess to 99

PYTHON superior over Haskell

You slow ass Haskellfags can suck your advisor's dick all day in grad school but you will eventually learn that int** is vastly superior to whatever broken piece of shit abstraction you are trying to talk about in this utter MEME of a language.

Yeah, I know enough about monads to call sequence on a list of Maybes, or to bind together a -> Either e a calls, but that's about it. Not there yet