|
Is this code readable by functional standards? I'm in the middle of writing my first non-trivial project in haskell and I don't know if it's total spaghetti or I'm just not used to reading functional code. I know it would be less clunky if I used a more appropriate data structure but that's what I've got to work with for now.code:
e: noticed a mistake right after I posted Magissima fucked around with this message at 18:01 on Mar 13, 2016 |
# ¿ Mar 13, 2016 17:58 |
|
|
# ¿ May 16, 2024 02:53 |
|
I think you're right that the problems originate from the data structure. The reason I have it that way is that this is from an assignment that was originally meant to be in java until the professor changed his mind and said we could use whatever, so I just directly took the java data structure and used that. It's obvious to me now that it makes a lot more sense to have a meaningful list index when you're working with loops than with functions, so lesson learned on that front. Thanks for the feedback!
|
# ¿ Mar 13, 2016 19:17 |
|
Whoa, that's way better than what I had. I don't think it even occurred to me to recurse to the correct list instead of manually indexing, but when you put it like that it makes total sense. I guess I'm still not used to thinking functionally. I probably should have come here before spending an hour banging my head against the wall coming up with my lovely solution. Thanks a lot for your help. I'll look into Data.Map as well.
|
# ¿ Mar 13, 2016 20:00 |
|
gonadic io posted:If we're being pedantic, then getGraphFromFile is a bad name and it should be called getGraphFromString. No files are involved at this stage. It was indeed originally FilePath -> IO [[Int]] but I didn't change the name when I moved the file access to main Also I tried out HLint and it seems pretty helpful, thanks for the recommendation.
|
# ¿ Mar 14, 2016 16:31 |