Lisplog

Blogging in Lisp

Search

Feed Aggregator

Rendered on Mon, 20 Jan 2020 00:02:52 GMT  newer latest older 
Next udpate: Mon, 20 Jan 2020 00:30:00 GMT feeds

List.reverse behaves strange

via Elm - Latest posts by @eriktimmers Erik Timmers on Sun, 19 Jan 2020 22:01:55 GMT

I guess you’re reversing the list multiple times. Try replacing that line with remainderBy 10 n :: getDigits (n // 10) to make getDigits a recursive function on its own.

List.reverse behaves strange

via Elm - Latest posts by @alexandru-calinoiu Calinoiu Alexandru Nicolae on Sun, 19 Jan 2020 20:56:23 GMT

Hi,

Trying out elm, I stumbled about this issue

module RippleCarryAdder exposing (digits)


digits : Int -> List Int
digits number =
    let
        getDigits n =
            if n == 0 then
                []

            else
                remainderBy 10 n :: digits (n // 10)
    in
    getDigits number
        |> List.reverse

digits 1000
[ 0, 1, 0, 0 ]

This is not what I’ve expected from the output, can someone please explain?

Review request for my toy elm project

via Elm - Latest posts by @kindlychung keenz on Sun, 19 Jan 2020 15:57:30 GMT

That’s very helpful, I’ve adopted all of your suggestions. :slight_smile:
Thanks!

How to disable elm tooling references and codelens for vscode editor

via Elm - Latest posts by @system system on Sun, 19 Jan 2020 10:09:25 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

How to create a round image in Elm-UI?

via Elm - Latest posts by @system system on Sun, 19 Jan 2020 07:49:40 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

 newer latest older