功能记录是否内存占用少?

时间:2017-04-18 09:44:50

标签: .net f# functional-programming pattern-matching record

据说我希望ThenByDescending使用Reservation。有许多类型的deposit,例如为普通客人预订,或贵宾,......(例如VIP可以在存入大量金钱时获得更高的折扣等)。

Reservation

如果我有很多记录,那么应用程序是否会占用大量内存?

至于上面的例子,我创建了一个私有的可变变量来存储钱,这很糟糕。如何在不将namespace RoomBooking type ReservationType = | Normal | VIP | Custom ... type Reservation = { ``type`` : ReservationType incrDeposit : decimal -> unit decrDeposit : decimal -> unit } module Reservation = let init deposit = function | Normal | Custom as t -> let mutable deposit = if deposit > 0m then deposit else 0m { ``type`` = t incrDeposit = fun d -> if d > 0m then deposit <- deposit + d decrDeposit = fun d -> if deposit > d then deposit <- deposit + d } | VIP -> ... let customInit incrDeposit decrDeposit = { ``type`` = Custom incrDeposit = incrDeposit decrDeposit = decrDeposit } 暴露给外部的情况下使功能正常工作?

0 个答案:

没有答案