RE: Hashcash Algorithm in F#

You are viewing a single comment's thread from:

Hashcash Algorithm in F#

in fsharp •  7 years ago 

You can get rid of mutation and further simplify your implementation:

let sender () =                                                                                                                                         
    let randomString = randomChars 8                                                                                                                    
    let counter = Seq.initInfinite ((+) 1)                                                                                                              
                  |> Seq.take 2000000  //limit so it does not run forever                                                                               
                  |> Seq.pick (fun index -> if compute index randomString then Some index else None)                                                    
    printfn "FINAL COUNT %i " counter                                                                                                                   
    printfn "HASH %s" (header counter randomString)      

and compute:

let compute index randomString =                                                                                                                        
    getHash (header index randomString) |> checkHash 
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you!