Skip to main content
Code Review

Return to Question

edited tags; edited title
Link
200_success
  • 145.5k
  • 22
  • 190
  • 478

F# Retrieve Convert bitcoin value based on exchange rate from JSON and do a simple calculationAPI

deleted 32 characters in body; deleted 10 characters in body
Source Link
MmM
  • 419
  • 2
  • 4
  • 10

I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin.

open System
open System.Net
open Newtonsoft.Json.Linq
let myBTC = 0.1234567
let client = new WebClient()
client.UseDefaultCredentials = true
let priceInfo = client.DownloadString("https://blockchain.info/ticker")
let jPrice : JObject = JObject.Parse priceInfo
let jEUReurPrice = float (jPrice.["EUR"].["buy"] :?> JValue 
let priceBTC : float = float jEUR)
let calcWorth = myBTC * priceBTCeurPrice
printfn "%s" calcWorth.ToString("N")

I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin.

open System
open System.Net
open Newtonsoft.Json.Linq
let myBTC = 0.1234567
let client = new WebClient()
client.UseDefaultCredentials = true
let priceInfo = client.DownloadString("https://blockchain.info/ticker")
let jPrice : JObject = JObject.Parse priceInfo
let jEUR = jPrice.["EUR"].["buy"] :?> JValue 
let priceBTC : float = float jEUR
let calcWorth = myBTC * priceBTC
printfn "%s" calcWorth.ToString("N")

I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin.

open System
open System.Net
open Newtonsoft.Json.Linq
let myBTC = 0.1234567
let client = new WebClient()
client.UseDefaultCredentials = true
let priceInfo = client.DownloadString("https://blockchain.info/ticker")
let jPrice = JObject.Parse priceInfo
let eurPrice = float (jPrice.["EUR"].["buy"] :?> JValue)
let calcWorth = myBTC * eurPrice
printfn "%s" calcWorth.ToString("N")
Source Link
MmM
  • 419
  • 2
  • 4
  • 10

F# Retrieve JSON and do a simple calculation

I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin.

open System
open System.Net
open Newtonsoft.Json.Linq
let myBTC = 0.1234567
let client = new WebClient()
client.UseDefaultCredentials = true
let priceInfo = client.DownloadString("https://blockchain.info/ticker")
let jPrice : JObject = JObject.Parse priceInfo
let jEUR = jPrice.["EUR"].["buy"] :?> JValue 
let priceBTC : float = float jEUR
let calcWorth = myBTC * priceBTC
printfn "%s" calcWorth.ToString("N")
lang-ml

AltStyle によって変換されたページ (->オリジナル) /