Difference between revisions of "To Squares With Functions Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
(Created page with "=Functions to Use= ==[https://smlfamily.github.io/Basis/list.html List Structure]== * [https://smlfamily.github.io/Basis/list.html#SIG:LIST.null:VAL null] * [https://smlfamily...")
 
Line 9: Line 9:
  
 
==to_squares==
 
==to_squares==
 +
A list of integers <code>xs</code> is passed to <code>to_squares</code>.  Evaluate to a list where each item is the square of its counterpart in the passed list.
 +
 
<syntaxhighlight lang="sml">
 
<syntaxhighlight lang="sml">
 
fun to_squares(xs : int list) : int list =
 
fun to_squares(xs : int list) : int list =
 
raise Fail "NotYetImplemented"
 
raise Fail "NotYetImplemented"
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
For example, if the passed list is <code>[1,2,3,4]</code> then <code>to_squares</code> would evaluate to <code>[1, 4, 9, 16]</code>.
  
 
=Test=
 
=Test=
 
{{SMLUnitTesting|run_squares_fun_testing|warmup_squares_fun}}
 
{{SMLUnitTesting|run_squares_fun_testing|warmup_squares_fun}}

Revision as of 14:47, 30 August 2024

Functions to Use

List Structure

Code to Implement

file: src/main/sml/warmup_squares_fun/my_length.sml Smlnj-logo.png
functions: to_squares

to_squares

A list of integers xs is passed to to_squares. Evaluate to a list where each item is the square of its counterpart in the passed list.

fun to_squares(xs : int list) : int list =
	raise Fail "NotYetImplemented"

For example, if the passed list is [1,2,3,4] then to_squares would evaluate to [1, 4, 9, 16].

Test

source folder: src/test/sml/warmup_squares_fun
how to run with CM.make verbosity off: sml -Ccm.verbose=false run_squares_fun_testing.sml
how to run with CM.make verbosity on: sml run_squares_fun_testing.sml

note: ensure that you have removed all printing to receive credit for any assignment.

SML Error Messages