3 ms·
All states should be defined? Then how to write an app takes two numbers and returns the sum?
by leowoo91 8y ago
All states should be defined? Then how to write an app takes two numbers and returns the sum?
- iNate2000 8y ago(Totally speculating here) I imagine the states would be something like "have no numbers", "have one number", and "have both numbers". And there would be some kind of transition in-to or out-of that third state that would specify the addition.
- klageveen 8y agoCheck this for an example: https://github.com/M-industries/AlanProjectTemplate/blob/master/interfaces/examples/application.alan#L116 https://github.com/M-industries/AlanProjectTemplate/blob/mas...
- leowoo91 8y agoThank you for the example. I just don't want to be picky but that is church encoding. To represent a number, say 1234567, you will need million items in a list.
- klageveen 8y agoAh, like that. It's a fair point, but you're interpreting the model at too low a level. You don't have to model all possible values of scalar types (number, text) because the implementation of all possible values is known. I.e. you're writing a model that will drive the behavior of the application in terms of business rules, with specifications that matter to users of the application.