(@ +-
    (# random-walk 5000 250 6.3225 12)
)

(@ random-walk experiments steps avg-step-size repeats +-
    (say 'Average' "\t\t" 'Probable' "\n")
    (.* 1..repeats >
        (say average "\t\t" probable -
             ((# calculate-average-distance experiments steps avg-step-size) # '0.00' -> .average) |
             ((# calculate-probable-distance steps avg-step-size) # '0.00' -> .probable)
        )
    )
)

(@ calculate-average-distance experiments steps avg-step-size +-
    (0 .divider .total ..)
    (.* 1..report._ i >
        (+= (# abs report.i) .total) 
        (++ .divider)
    -
        (# repeat-random-walks experiments steps avg-step-size .report)
    )
    ([> 0] divider >
        ((/ divider) total)
    >
        (exit ERR_EMPTY_VARIABLE) 
    )
)

(@ repeat-random-walks experiments steps avg-step-size .report +-
    (.* 1..experiments .report >
        (# do-random-walk steps avg-step-size)
    )
+
    {integer} experiments 
    {array : integer} report
)

(@ do-random-walk steps avg-step-size .distance +-
    (.* 1..steps >
        ([= 1] (# rand 0 1) >
            (+= (* 2 (# rand 1 avg-step-size)) .distance)
        >
            (-= (* 2 (# rand 1 avg-step-size)) .distance)
        )
    )
+
    {integer} steps avg-step-size
    {integer : +-} distance
)

(@ calculate-probable-distance steps avg-step-size +-
    (* (# sqrt steps) avg-step-size)
+
    {integer} steps avg-step-size
)