Effective Solutions for SML Programming Issues

cse 341 n.w
1 / 8
Embed
Share

Discover effective solutions for common SML programming issues, including local variable definition, mutual recursion, and utilizing SML documentation to enhance your coding skills and avoid redundant implementations.

  • SML Programming
  • Solutions
  • Documentation
  • Mutual Recursion
  • Higher Order Functions

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CSE 341 Section 3 Justin Harjanto

  2. Agenda HW2 Issues SML Docs for HW3 More functions Java 8 Streams

  3. The problem fun earlier x = ... other x ... fun later x = ... other x ... fun other x = earlier x ... later x ... The above doesn t work because earlier and later don t have reference to the other binding!

  4. Solutions? If earlier and later aren t used anywhere else, then have other define them locally instead! fun other x = let fun earlier x ... fun later x ... in earlier x ... later x ... end

  5. Or use mutual recursion! In HW2, there are some problems where you want this This is a common idiom in SML and other languages Mutual recursion uses the and keyword fun even 0 = true | even n = odd (n - 1) and odd 0 = false | odd n = even (n - 1)

  6. SML Docs Useful skill to look at docs! Don t want to reimplement something that s already in standard lib Two of the most useful pages for this next homework: http://sml-family.org/Basis/string.html http://sml-family.org/Basis/list.html

  7. Higher Order Functions See code!

Related


More Related Content