-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify and remove unnecessary files for the assignment (#7)
* Remove `main` interpreter runner We remove the top-level main because we really only need testing. * Remove autograding workflow * Remove autograding workflow * Update build and .gitignore * Remove grader and util files * Remover file-based tester * Standardize locations to **/jsy/lab1 * Clean up student files - Remove extra interfaces - Remove external test files - Add more comments * Add .scalafmt.conf * Update build.sbt
- Loading branch information
Showing
27 changed files
with
475 additions
and
1,050 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
.idea | ||
# sbt | ||
target/ | ||
project/target/ | ||
project/project/ | ||
project/target/* | ||
project/project/* | ||
.ivy2 | ||
.sbt | ||
|
||
# Intellj | ||
.idea | ||
|
||
# VS Code | ||
.vscode | ||
|
||
# Metals | ||
.metals | ||
.bloop | ||
metals.sbt | ||
.bsp | ||
|
||
# Ammonite | ||
.ammonite | ||
|
||
# macOS | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version = "3.7.15" | ||
runner.dialect = scala213 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.5.2 | ||
sbt.version=1.10.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package jsy.lab1 | ||
|
||
object Lab1 { | ||
/* | ||
* CSCI 3155: Lab 1 | ||
* <Your Name> | ||
* | ||
* Partner: <Your Partner's Name> | ||
* Collaborators: <Any Collaborators> | ||
*/ | ||
|
||
/* | ||
* Fill in the appropriate portions above by replacing things delimited | ||
* by '<'... '>'. | ||
* | ||
* Replace the '???' expression with your code in each function. The | ||
* '???' expression is a Scala expression that throws a NotImplementedError | ||
* exception. | ||
* | ||
* Your lab will not be graded if it does not compile. | ||
* | ||
* This template compiles without error. Before you submit comment out any | ||
* code that does not compile or causes a failing assert. Simply put in a | ||
* '???' as needed to get something that compiles without error. | ||
*/ | ||
|
||
/* | ||
* Example: Test-driven development of `plus` | ||
* | ||
* A convenient, quick-and-dirty way to experiment, especially with small code | ||
* fragments, is to use the interactive Scala interpreter. The simplest way | ||
* to use the interactive Scala interpreter is through a worksheet, such as | ||
* Lab1.worksheet.sc. A Scala Worksheet is code evaluated in the context of | ||
* the project with results for each expression shown inline (somewhat like a | ||
* Jupyter notebook). | ||
* | ||
* Step 0: Sketch an implementation in Lab1.scala using ??? for unimplemented things. | ||
* Step 1: Do some experimentation in Lab1.worksheet.sc. | ||
* Step 2: Write a test in Lab1Spec.scala, which should initially fail because of the ???. | ||
* Step 3: Fill in the ??? here to finish the implementation to make your test pass. | ||
*/ | ||
|
||
//def plus(x: Int, y: Int): Int = ??? | ||
def plus(x: Int, y: Int): Int = 0 | ||
// def plus(x: Int, y: Int): Int = x + y | ||
|
||
/* Exercises */ | ||
|
||
def repeat(s: String, n: Int): String = ??? | ||
|
||
def sqrtStep(c: Double, xn: Double): Double = ??? | ||
|
||
def sqrtN(c: Double, x0: Double, n: Int): Double = ??? | ||
|
||
def sqrtErr(c: Double, x0: Double, epsilon: Double): Double = ??? | ||
|
||
def sqrt(c: Double): Double = { | ||
require(c >= 0) | ||
if (c == 0) 0 else sqrtErr(c, 1.0, 0.0001) | ||
} | ||
|
||
/* Search Tree */ | ||
|
||
sealed abstract class Tree | ||
case object Empty extends Tree | ||
case class Node(l: Tree, d: Int, r: Tree) extends Tree | ||
|
||
def repOk(t: Tree): Boolean = { | ||
def check(t: Tree, min: Int, max: Int): Boolean = t match { | ||
case Empty => true | ||
case Node(l, d, r) => ??? | ||
} | ||
check(t, Int.MinValue, Int.MaxValue) | ||
} | ||
|
||
def insert(t: Tree, n: Int): Tree = ??? | ||
|
||
def deleteMin(t: Tree): (Tree, Int) = { | ||
require(t != Empty) | ||
(t: @unchecked) match { | ||
case Node(Empty, d, r) => (r, d) | ||
case Node(l, d, r) => | ||
val (l1, m) = deleteMin(l) | ||
??? | ||
} | ||
} | ||
|
||
def delete(t: Tree, n: Int): Tree = ??? | ||
|
||
/* Evaluate the JavaScripty Calculator Language */ | ||
|
||
/* We import `jsy.lab1.ast._` so that we can make use of the Expr type defined | ||
* there. Take a look at ast.scala to see what the Expr type looks like, as well | ||
* some helper functions for defining values (`isValue`) and pretty-printing | ||
* (`pretty`) that you are welcome to use. | ||
*/ | ||
import jsy.lab1.ast._ | ||
|
||
def eval(e: Expr): Double = e match { | ||
case N(n) => ??? | ||
case _ => ??? | ||
} | ||
|
||
/* We also overload `eval` to take a String and parse it into an Expr and then | ||
* evaluate it using your `eval` function defined above. | ||
*/ | ||
def eval(e: String): Double = eval(Parser.parse(e)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* CSCI 3155: Lab 1 Worksheet | ||
* | ||
* This worksheet demonstrates how you could experiment | ||
* interactively with your implementations in Lab1.scala. | ||
*/ | ||
|
||
/* | ||
* Example: Test-driven development of `plus` | ||
*/ | ||
|
||
/* Here we can write expressions to experiment with how we might implement | ||
* something. The expression is evaluated interactively. | ||
*/ | ||
1 + 1 | ||
val n = 1 + 1 | ||
n + 3 | ||
|
||
/* The worksheet is built with all of the project files, so we can call | ||
* a function from your `jsy.lab1.Lab1` object (in Lab1.scala). | ||
*/ | ||
//jsy.lab1.Lab1.plus(3, 4) | ||
|
||
/* We can imports all of the functions from your `jsy.lab1.Lab1` object. */ | ||
import jsy.lab1.Lab1._ | ||
//plus(3, 4) | ||
|
||
/* We can check the implementation here, though it better to write tests | ||
* in Lab1Spec.scala. | ||
*/ | ||
//assert(plus(1, 1) == 2) | ||
|
||
/* Braces {} can be used wherever parentheses () can be (but not the other | ||
* way around). Braces {} introduce scope, while () do not. | ||
*/ | ||
// assert { | ||
// val two = 2 | ||
// plus(1, 1) == two | ||
// } | ||
|
||
/* Exercises */ | ||
|
||
//assert(repeat("a", 3) == "aaa") | ||
|
||
/* We import jsy.lab.ast._ to use the AST nodes. */ | ||
import jsy.lab1.ast._ | ||
|
||
/* A parser defines how to translate concrete syntax (i.e., strings a programmer types) | ||
* into an abstract syntax tree (AST) that we use to evaluate the program. A parser | ||
* is given to you in jsy.lab1.Parser. You can use the parser to parse a String into | ||
* an Expr. | ||
* | ||
* Here are some shortcuts to that parser for your reference. | ||
* */ | ||
import jsy.lab1.Parser | ||
def parse(s: String): Expr = Parser.parse(s) | ||
def parseFile(filename: String): Expr = Parser.parseFile(filename) | ||
|
||
/* Call the parser (from the provided library) on a string */ | ||
parse("-4") | ||
|
||
val negFourAST = parse("-4") | ||
assert { | ||
negFourAST match { | ||
case Unary(_, _) => true | ||
case _ => false | ||
} | ||
} | ||
|
||
/* Evaluate that `negFourAST` expression. */ | ||
//eval(negFourAST) | ||
|
||
/* For convenience, we also have an overloaded `jsy.lab1.Lab1.eval` function that takes | ||
* a String, calls the parser, and then delegates to your `eval` function. | ||
*/ | ||
//eval("1 + 1") |
Oops, something went wrong.