Tags » F

Property-based testing

Unit testing. We all do it. Some of us even practice TDD (although I wish I had a penny for each time I see a company claiming that they practice TDD when what they actually mean is “We write unit tests.”). 1,029 more words

General Chat






作者 yasgale (在我還沒睜開眼之前) 看板 bookhouse

標題 [情報] 台大後門的販讀要結束營業了

時間 Sat May 3 17:29:45 2008




唉呀呀 又少了一家便宜的好書店了


F#: Practicing Units of Measure

I decided to create my own car kata.
In doing so, I decided to leverage the UOM (Unit of Measure) feature in F#. This essentially constrains how one calculates values that are associated to specific units of measure. 195 more words

Software Development

F#: Revisiting the Vending Machine (again)

I really do enjoy the Vending Machine kata. I decided on the late night to revisit it.

module TempImpl

type Product = Gum     | Chips | Soda
type Coin =    Quarter | Dime  | Nickel

type Change =  Change of Coin list

type Transaction =
    | Purchased  of Product * Change
    | Required   of decimal
    | OutOfStock of Product

let priceOf = function
              | Gum   -> 0.25m
              | Chips -> 0.50m
              | Soda  -> 1.00m

let valueOf = function
              | Quarter -> 0.25m
              | Dime    -> 0.10m
              | Nickel  -> 0.05m

let balanceOf coins =
    (0.0m , coins) 
    ||> List.fold (fun balance coin -> balance + (valueOf coin))
let remaining balance product = (priceOf product) - balance
let rec getChange balance change =
    let rec get remaining change =

        if remaining >= valueOf Quarter
        then get (remaining - valueOf Quarter) (Quarter::change)
        elif remaining >= valueOf Dime
        then get (remaining - valueOf Dime) (Dime::change)
        elif remaining >= valueOf Nickel
        then get (remaining - valueOf Nickel) (Nickel::change)
        else change
    get balance []

let select product deposited products =

    if not (products |> List.contains product)
    then OutOfStock product

    elif balanceOf deposited >= priceOf product
    then Purchased (product , Change <| getChange (balanceOf deposited - priceOf product) [])
    else Required (priceOf product - balanceOf deposited)

let products = [ Gum ; Chips ; Soda ]
               |> select Gum 
… 17 more words
Software Development

Is Fiat Chrysler in the Same Emissions Mess as Volkswagen?

It turns out that Volkswagen may not have been the only car company that in the wrong on emissions. Reports that Fiat Chrysler Automobiles N.V. (NYSE: FCAU) is now being targeted by the Environmental Protection Agency (EPA) have put a serious hurt on shares of the carmaker. 786 more words


The 6 Most Shorted NYSE Stocks

The Trump rally seemed to weaken as the year wound to its conclusion, while many investors and traders were out for the holidays. Yet with markets still near all-time highs, those short sellers got out of the way of some of the most shorted stocks traded on the New York Stock Exchange between the December 15 and December 30 settlement dates. 922 more words


SqlJuxt - Building primary keys on a table

There were a few interesting design decisions I had to make when designing the code to script a primary key on a table. Before I dive into them I think it is good to see the finished code, here is a test that uses the TableBuilder to create a clustered primary key on a table: 740 more words