Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cse341 23au Public
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cse341-23au
Cse341 23au Public
Commits
6778c4ec
Commit
6778c4ec
authored
1 year ago
by
James R. Wilcox
Browse files
Options
Downloads
Patches
Plain Diff
draft sec01 worksheet
parent
b7b893fd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
section/sec01/sec01.ml
+42
-0
42 additions, 0 deletions
section/sec01/sec01.ml
with
42 additions
and
0 deletions
section/sec01/sec01.ml
0 → 100644
+
42
−
0
View file @
6778c4ec
(* Edit this binding's value so that it is about the current air temperature in Fahrenheit. *)
let
temp_f
:
float
=
55
.
0
(* Write a binding for a variable temp_c that is the conversion of temp_f to Celsius. *)
(* YOUR BINDING HERE *)
(* What edits would you need to make to change the computations above to be over ints instead of floats?
(Don't actually make the edits, just say what you would do at a high level.) *)
(* YOUR ANSWER HERE *)
(* Write a function c_of_f of type float -> float that converts its argument from Fahrenheit to Celsius.
Hint: remind yourself how to define a function from lecture. *)
(* YOUR BINDING HERE *)
(* Write a test for your c_of_f implementation. (Remember that for HW1, a test is just a variable binding
that calls the function and checks its output.) *)
(* YOUR TEST HERE *)
(* James feels cold when it is below 20 degrees Celsius. Write a function is_james_cold that takes a
*Fahrenheit* temperature as an argument (of type float) and returns a bool indicating whether
James is cold. *)
(* YOUR BINDING HERE *)
(* Write two tests for is_james_cold that cover both the case where James is cold and the case where
he is not cold. *)
(* YOUR FIRST TEST HERE *)
(* YOUR SECOND TEST HERE *)
(* Write a binding for a variable called msg1 of type string that says "James is cold" if James is
currently cold and "James is not cold" otherwise. Call is_james_cold on the current temperature,
use that to compute the right string. *)
(* YOUR BINDING HERE *)
(* Write a function sum_of_first_n_ints of type int -> int that takes an argument n and returns the
sum of the first n numbers. (Use recursion because we don't have loops!) *)
(* YOUR BINDING HERE *)
(* Write three tests for sum_of_first_n_ints that cover the "0", "1", and "many" cases of the recursion. *)
(* YOUR FIRST TEST HERE *)
(* YOUR SECOND TEST HERE *)
(* YOUR THIRD TEST HERE *)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment