Nicholas Shahan Spring 2016

Slides:



Advertisements
Similar presentations
CSE341: Programming Languages Lecture 12 Modules Dan Grossman Fall 2011.
Advertisements

CSE341: Programming Languages Lecture 7 Functions Taking/Returning Functions Dan Grossman Fall 2011.
CSE 341 : Programming Languages Lecture 12 ML Modules Zach Tatlock Spring 2014.
CSE 341 : Programming Languages Lecture 8 First Class Functions Zach Tatlock Spring 2014.
1.SML Docs Standard Basis 2.First-Class Functions Anonymous Style Points Higher-Order 3.Examples Agenda.
CSE341: Programming Languages Lecture 11 Type Inference
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 10 ML Modules
CSE341: Programming Languages Lecture 7 First-Class Functions
CSE 341 Section 9 Nick Mooney Spring 2017
CSE341: Programming Languages Lecture 9 Function-Closure Idioms
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Spring 2013.
Nicholas Shahan Spring 2016
Emily Leland (Not Nick) Spring 2017
CSE 341: Programming Languages Section 1
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Spring 2017.
CSE341: Programming Languages Section 1
CSE341: Programming Languages Lecture 9 Function-Closure Idioms
CSE341: Programming Languages Lecture 10 ML Modules
With thanks to Nick Mooney & Spencer Pearson
CSE 341 Section 1 Nick Mooney Spring 2017
CSE341: Programming Languages Section 1
CSE 341 Section 4 Nick Mooney Spring 2017.
Nicholas Shahan Spring 2016
CSE 341 Section 9 Winter 2018 Adapted from slides by Eric Mullen, Nick Mooney, Nicholas Shahan, Cody Schroeder, and Dan Grossman.
CSE341: Programming Languages Lecture 7 First-Class Functions
Nicholas Shahan Spring 2016
Agenda SML Docs First-Class Functions Examples Standard Basis
Agenda SML Docs First-Class Functions Examples Standard Basis
CSE341: Programming Languages Lecture 7 First-Class Functions
CSE 341 Section 2 Winter 2018 Adapted from slides by Nick Mooney, Nicholas Shahan, Patrick Larson, and Dan Grossman.
CSE341: Programming Languages Lecture 10 ML Modules
CSE341: Programming Languages Lecture 9 Function-Closure Idioms
CSE 341: Programming Languages Section 1
CSE 341 Section 5 Winter 2018.
CSE341: Programming Languages Lecture 9 Function-Closure Idioms
CSE341: Programming Languages Lecture 11 Type Inference
CSE341: Programming Languages Lecture 9 Function-Closure Idioms
CSE341: Programming Languages Lecture 10 ML Modules
Spencer Pearson Spring 2017
CSE 341 Section 2 Nick Mooney Spring 2017
Adapted from slides by Nicholas Shahan and Dan Grossman
CSE 341 Section 3 Nick Mooney Spring 2017.
341 midterm review Xinrong Zhao Autumn 2018.
Nicholas Shahan Spring 2016
CSE-321 Programming Languages Introduction to Functional Programming
Adapted from slides by Nicholas Shahan, Dan Grossman, and Tam Dang
CSE 341 Section 4.
CSE341: Programming Languages Lecture 10 ML Modules
CSE341: Programming Languages Lecture 7 First-Class Functions
Nicholas Shahan Spring 2016
With thanks to Nick Mooney, Spencer Pearson & Alexander Lent
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Spring 2016.
Section 4 CSE 341 – Konstantin Weitz.
CSE341: Programming Languages Lecture 7 First-Class Functions
CSE341: Programming Languages Lecture 11 Type Inference
CSE 341 Section 9 Fall 2017 Adapted from slides by Nick Mooney, Nicholas Shahan, Cody Schroeder, and Dan Grossman.
With thanks to Alexander Lent, Nick Mooney, Spencer Pearson
CSE341: Programming Languages Lecture 7 First-Class Functions
CSE341: Programming Languages Lecture 11 Type Inference
CSE341: Programming Languages Lecture 10 ML Modules
CSE341: Programming Languages Lecture 9 Function-Closure Idioms
CSE341: Programming Languages Lecture 7 First-Class Functions
CSE341: Programming Languages Section 1
CSE341: Programming Languages Lecture 7 First-Class Functions
CSE341: Programming Languages Lecture 10 ML Modules
CSE341: Programming Languages Lecture 11 Type Inference
Higher-Order Functions and Closures
CSE341: Programming Languages Lecture 15 Macros
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Spring 2019.
Presentation transcript:

Nicholas Shahan Spring 2016 CSE 341 Section 4 Nicholas Shahan Spring 2016 Adapted from slides by Cody A. Schroeder, and Dan Grossman

Today’s Agenda Mutual Recursion Module System Example Namespace Organization Preserving Invariants Practice with Currying and High Order Functions

Mutual Recursion What if we need function f to call g, and function g to call f? This is a common idiom fun earlier x = ... later x fun later x = earlier x Unfortunately this does not work 

Mutual Recursion Workaround We can use higher order functions to get this working It works, but there has got to be a better way! fun earlier (f, x) = ... f x fun later x = earlier (later, x)

Mutual Recursion with and SML has a keyword for that Works with mutually recursive datatype bindings too fun earlier x = ... later x and later x = earlier x

Module System Good for organizing code, and managing namespaces (useful, relevant) Good for maintaining invariants (interesting)

Currying and High Order Functions List.map! List.filter! List.foldl! Emacs unite!