sml

How can I easily write simple tactics at the ML level of Isabelle?

删除回忆录丶 提交于 2021-02-18 05:20:26
问题 In an Isabelle theory file, I can write simple one-line tactics such as the following: apply (clarsimp simp: split_def split: prod.splits) I find, however, when I start writing ML code to automate proofs, to produce an ML tactic object, these one-liners become rather verbose: clarsimp_tac (Context.proof_map ( Simplifier.map_ss (fold Splitter.add_split @{thms prod.splits}) #> Simplifier.map_ss (fn ss => ss addsimps [@{thm split_def}])) @{context}) 1 Is there an easier way to write the simple

ML IDE and Compiler for Windows or Linux or Mac

爷,独闯天下 提交于 2021-02-17 07:45:09
问题 I have to write some code in ML and it is my first time I`m going to use the language. Is there any Development Environment for Standard ML? (preferably under Windows). I tried googling (and stackOverFlowing ! ) but all I found was plain compilers for Linux (at most with an interactive console), but no IDE nor Eclipse/NetBeans plugin. Any suggestions ? 回答1: How to Configure SML with Sublime Text 2 For those who prefer Sublime Text instead of Emacs as the editor of choice to program SML, the

number_in_month exercise (Getting EQUAL. OP Error in SML, One function works other does not)

隐身守侯 提交于 2021-02-11 13:26:49
问题 (* Write a function number_in_month that takes a list of dates and a month (i.e., an int) and returns how many dates in the list are in the given month.*) fun number_in_month(datelist : (int*int*int) list, month : int) = if null(tl (datelist)) then if #2(hd (datelist)) = month then 1 else 0 else if #2(hd (datelist)) = month then 1 + number_in_month(tl datelist, month) else number_in_month(tl datelist, month) (* Write a function number_in_months that takes a list of dates and a list of months

operator and operand don't agree [tycon mismatch] - sml assuming the wrong list type

…衆ロ難τιáo~ 提交于 2021-02-10 20:29:51
问题 I have a pretty simple code that's supposed to transform a list of tuples (int * string), into two lists, one list of ints and one list of strings - basically a list of tuples into a tuple of lists. fun unzip_single_int[] : int list = [] | unzip_single_int(x::xs) : int list = x :: unzip_single_int(xs) fun unzip_single_string[] : string list = [] | unzip_single_string(x::xs) : string list = x :: unzip_single_string(xs) fun unzip[] : (int list * string list) = ([], []) | unzip([twopls]) : (int

operator and operand don't agree [tycon mismatch] - sml assuming the wrong list type

十年热恋 提交于 2021-02-10 20:29:49
问题 I have a pretty simple code that's supposed to transform a list of tuples (int * string), into two lists, one list of ints and one list of strings - basically a list of tuples into a tuple of lists. fun unzip_single_int[] : int list = [] | unzip_single_int(x::xs) : int list = x :: unzip_single_int(xs) fun unzip_single_string[] : string list = [] | unzip_single_string(x::xs) : string list = x :: unzip_single_string(xs) fun unzip[] : (int list * string list) = ([], []) | unzip([twopls]) : (int

number_in_month exercise (Why x = x + 1 is considered bool in sml while x is int and how to say x = x + 1 correctly?)

孤人 提交于 2021-02-08 09:22:27
问题 Update: What I want to do with this code is to get a list of dates, year/month/day and a given number as a month, and check to see how many of the dates in the given list are in the same month as that given month. What I meant of x = x + 1 was x++ such as in java or C or C#. As the output I want x. if there is no match, 0 and for any match x = x + 1 So this is my code, fun number_in_month (Dlist : (int * int * int) list, Month : int, x : int) = if null Dlist then x else if #2 (hd Dlist) =

How to compile SML using SMLNJ while the code is in Notepad++?

醉酒当歌 提交于 2021-01-29 17:30:45
问题 I'm completely new to SML and I have no idea how to work with anything related to it. I am supposed to use the SMLNJ compiler and I'm currently coding using Notepad++. But how do I compile the program exactly? Do I copy and paste the code in the SMLNJ command line thing? Or is there an environment for SMLNJ I can actually code in and compile my code? PLEASE HELP! 回答1: If by "compile" you mean "compile to a stand-alone executable" -- don't worry about that when first learning the language as a

number_in_month exercise (SML recursive function on list interation)

大兔子大兔子 提交于 2021-01-29 07:39:04
问题 I found this code on another SO post: fun number_in_month ([], _) = 0 | number_in_month ((_,x2,_) :: xs, m) = if x2 = m then 1 + number_in_month(xs, m) else number_in_month(xs, m) and to my surprise it works. - number_in_month ([(2018,1,1),(2018,2,2),(2018,2,3),(2018,3,4),(2018,2,30)],2); val it = 3 : int My confusion is first unfamiliarity with this form of classic mathematical recursive function (I'm a beginner), then how it actually steps through the list. My intuition would have the

number_in_month exercise (Error: syntax error: replacing COLON with AS)

喜欢而已 提交于 2021-01-29 06:16:36
问题 this is homework from the ProgLang course at Coursera but the due date has passed and I'm only auditing this. This is a really cheap problem but it looks like I can't do this in SML. Given a list of date 3-tuples of int and an int, return how often that int matches #2 of the tuple (the month). At first I had a lot of [tycon mismatch] and then played around with the function header. I have no idea how to denote a list of tuples, prolly all down to that. fun number_in_month (date : [int*int*int

Generating a random number in SML

折月煮酒 提交于 2021-01-27 16:00:39
问题 How can you generate a random number from a specific range, for example the integer 34 in the range [1, 100]? I looked at the Random structure but it doesn't give me what I want, at least from what I can understand. 回答1: I think you have to use the Random structure in the given link like this ... - val nextInt = Random.randRange (1,100); - val r = Random.rand (1,1); - val x1 = nextInt r; - val x2 = nextInt r; 回答2: To get 34 integers between 1 and 100, you could use: let val seed = Random.rand