Jump to content

Ok so long story short, I need to do some ML programming for a Programming Language Concepts class. There is a language (accent) barrier with my professor, and she doesn't for whatever reason distribute her notes. The assignment is simple, but I literally have no idea what the fuck to do. None of us do. Can someone please point me to a reliable online source for smlnj? Most things I'm finding aren't very helpful or are disorganized.

Link to comment
https://linustechtips.com/topic/839618-standard-ml-smlnj/
Share on other sites

Link to post
Share on other sites

Unfortunately, there aren't a huge number of resources available for SML. A recommended text book for my SML module was ML for the Working Programmer, which seemed fairly god, though our course used Poly/ML rather than SML/NJ (though they should be quite similar, and I don't think the text book was specific to it). We didn't use much of the book in our fundamentals course, but there is quite a wide range of content in there. It doesn't appear to be available online legitimately though, so you would need to buy it or get it from a library to have a legal copy.

HTTP/2 203

Link to comment
https://linustechtips.com/topic/839618-standard-ml-smlnj/#findComment-10486879
Share on other sites

Link to post
Share on other sites

9 hours ago, colonel_mortis said:

Unfortunately, there aren't a huge number of resources available for SML. A recommended text book for my SML module was ML for the Working Programmer, which seemed fairly god, though our course used Poly/ML rather than SML/NJ (though they should be quite similar, and I don't think the text book was specific to it). We didn't use much of the book in our fundamentals course, but there is quite a wide range of content in there. It doesn't appear to be available online legitimately though, so you would need to buy it or get it from a library to have a legal copy.

Thanks for the help, I'll look into it. Its just quite frustrating cause the assingment itself is super easy. Basically the program needs to take in some integer n, and print "hello world" n times.

 

FUCKING (please excuse my language) simplest thing ever. Literally if it was any other language it would be for(int i = 0; i < n; i++) {print("hello world"}. But its my understanding ML is a functional language not Obj Oriented, so like I'm looking at an entirely different thought process here

Link to comment
https://linustechtips.com/topic/839618-standard-ml-smlnj/#findComment-10488850
Share on other sites

Link to post
Share on other sites

10 hours ago, BrownZeus said:

Thanks for the help, I'll look into it. Its just quite frustrating cause the assingment itself is super easy. Basically the program needs to take in some integer n, and print "hello world" n times.

 

FUCKING (please excuse my language) simplest thing ever. Literally if it was any other language it would be for(int i = 0; i < n; i++) {print("hello world"}. But its my understanding ML is a functional language not Obj Oriented, so like I'm looking at an entirely different thought process here

ML is a functional language, so rather than using loops (which do exist but aren't really central to the language), you should use recursion. In each recursive call, you want to print "Hello world", and call the function with n-1, until n=0. That would look something like

fun helloWorld (n) = if n = 0 then ""
                     else  "Hello World\n" ^ helloWorld(n-1)

I can't remember the exact syntax though, especially with respect to strings, so that might not be exactly right. There are a couple of other ways that it can be written to mean the same thing, but that format should be closest to what you'd be familiar with in other languages, and is likely to be what your lecturer started with.

HTTP/2 203

Link to comment
https://linustechtips.com/topic/839618-standard-ml-smlnj/#findComment-10490043
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×