
Hi,
For what it's worth, Daniel's suggestion of:
```haskell
isAlphabetic char = elem char ['A'..'Z']
```
does read nicer but would have to traverse `['A'..'Z']` every time. I think
what you have is fine, and although relational and boolean operators are
also in imperative languages, they behave as pure functions even in
imperative languages if subexpressions don't cause side effects. I don't
think it's unidiomatic, and especially in this case, "between A and Z"
means the same thing as "is one of the letters A, B, C...Z", so the intent
of the function is clear as written.
Best of all would probably be using `isAlpha` from `Data.Char` (in `base`).
Best,
toz
On Wed, May 20, 2020 at 2:41 PM
Send Beginners mailing list submissions to beginners@haskell.org
To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-request@haskell.org
You can reach the person managing the list at beginners-owner@haskell.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..."
Today's Topics:
1. Code Review of Caesar-Cipher (chrysaetos99) 2. Re: Code Review of Caesar-Cipher (Daniel van de Ghinste)
----------------------------------------------------------------------
Message: 1 Date: Wed, 20 May 2020 20:26:37 +0200 From: chrysaetos99
To: beginners@haskell.org Subject: [Haskell-beginners] Code Review of Caesar-Cipher Message-ID: Content-Type: text/plain; charset="utf-8"; Format="flowed" Background ---------- I am a total beginner in Haskell, so after reading the "Starting out"-chapter of "Learn you a Haskell", I wanted to create my first program that actually does something.
I decided to do the famous Caesar-Cipher.
Code ---- See attachment.
Question(s)
-----------
- How can this code be improved in general? - Do I follow the style guide of Haskell (indentation, etc.)? - I have a background in imperative languages. Did I do something that is untypical for functional programming languages?
I would appreciate any suggestions.
---
Please note: I also asked this question on
https://codereview.stackexchange.com/questions/242529/caesar-cipher-implemen...,
but didn't receive an answer that really answered all my questions.
Kind regards
chrysaetos99