smlnj

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 (Tycon Mismatch Error In SML function which tries to build a list)

本小妞迷上赌 提交于 2021-01-29 10:10:08
问题 (* Write a function dates_in_month that takes a list of dates and a month (i.e., an int) and returns a list holding the dates from the argument list of dates that are in the month. The returned list should contain dates in the order they were originally given. *) fun dates_in_months( datelist : (int*int*int) list, month : int) = if null(tl (datelist)) then if #2(hd (datelist)) = month then #2(hd (datelist)) :: [] else [] else if #2(hd (datelist)) = month then #2(hd (datelist)) :: number_in

number_in_month exercise (Don't understand why I'm getting “Syntax Error at EOF” in SML)

一曲冷凌霜 提交于 2021-01-29 04:45:11
问题 I'm supposed to write a program that takes a list of dates and then a month and returns the number of dates that include the month. I keep getting a syntax error and I don't understand why. fun number_in_month (dates : int list, month : int) = let val tally = 0 in let fun tally_counter(tally_dates : int list)= if (tally_dates[1]) = month then ( tally = tally + 1 tally_counter(tl tally_dates) ) else if null (hd tally_dates) then tally in tally_counter(dates) end 回答1: It looks like you're

How to read string from user keyboard in SML language?

£可爱£侵袭症+ 提交于 2020-06-29 04:23:50
问题 I am new to the SML language and I want to do this: to ask a person "what is your full name?" to get answer from user's keyboard and to write "your full name is"+name (his or her name that answered) 回答1: This answer has three parts. The first part answers your only question. The second part answers a question you seem to be fishing for without asking it, and the third part addresses how to find answers to questions by your own means. How to read string from user keyboard in SML language? You

what does “syntax error found at EOF” means and why am i getting it for this recursive function?

浪子不回头ぞ 提交于 2020-03-23 14:43:05
问题 I'm getting the error in SMLNJ: Error: syntax error found at EOF what does this means? The function that seems to be causing the error is the following. fun number_in_month (dates : int*int*int list, month : int) = if null dates then 0 else if #2 (hd dates) = month then number_in_month(tl dates, month) + 1 It is supposed to take a list of dates ( int*int*int list) and a month ( int ) and returns how many dates in the list are in the given month. Thanks for your kind help. 来源: https:/