Chapter 1 Task 9 question #510
Replies: 4 comments 1 reply
-
I think I got it:
|
Beta Was this translation helpful? Give feedback.
-
@RazzorLabs Yes, that looks like a correct solution 🙂 |
Beta Was this translation helpful? Give feedback.
-
I am fighting with Task 10 in Chapter 1. I have came with one idea how to do it. So I would like to split number on digits with:
After that I would like to apply "head" on the list of char which should be working: *Main> head [1, 4, 5] but I have no idea how to filter the ouptut using the head in the function which I have created. I know this is probably not the best solution but how can I do it this way? thx |
Beta Was this translation helpful? Give feedback.
-
@RazzorLabs I'm not sure I understand your question. But if you write a separate function firstDigit :: Integer -> Integer
firstDigit n = head (splitDigits n) |
Beta Was this translation helpful? Give feedback.
-
Hi,
So I am trying to figure out how to solve this. I am able to sum all digits:
sumLastTwo 0 = 0 sumLastTwo x = (x
mod10) + sumLastTwo (x
div10)
With
mod
I can get last digit, but how to take number before the last one?I have tried to break digit in to the characters but no idea how to work with output afterwards.
Beta Was this translation helpful? Give feedback.
All reactions