# LeetCode 2816. Double a Number Represented as a Linked List in F#

## URL

Double a Number Represented as a Linked List - LeetCode

## Code

```
type MyList =
| Leaf
| Node of int * MyList
let doubleIt (head: MyList) : MyList =
let rec doubleIt' node =
match node with
| Leaf -> Leaf, 0
| Node(v, next) ->
let lst, carry = doubleIt' next
let v' = v * 2 + carry
if v' >= 10 then Node(v' % 10, lst), 1 else Node(v', lst), 0
let lst, carry = doubleIt' head
if carry > 0 then Node(1, lst) else lst
```