Hi all,

I'm pretty new to the language. I tried the following snippet:
    
    
    import sequtils
    import sugar
    import bigints
    
    const
        n =  15
    
    proc product[T](data: seq[T]) {.thread.} =
        echo "data=" , data
        echo foldl(data, a * b)
    
    proc sum[T](data: seq[T]) {.thread.} =
        echo "data=" , data
        echo foldl(data, a + b)
    
    # build a sequence of first n big integers
    var firstN1 = toSeq(1..n)
    var firstN2 = toSeq(1..n).map(i => initBigInt(i))
    
    sum(firstN1)
    sum(firstN2)
    
    product(firstN1)
    product(firstN2)
    
    
    Run

The last function is giving me a runtime error:
    
    
    data=@[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    120
    data=@[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    120
    data=@[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    1307674368000
    data=@[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    Error: unhandled exception: index out of bounds, the container is empty 
[IndexError]
    Error: execution of an external program failed: ''post' '
    
    
    Run

Any hint?

Reply via email to