Difference between revisions of "Dynamic Spreadsheet Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 27: Line 27:
  
 
=Code To Implement=
 
=Code To Implement=
For clarity, we will provide what select functions evaluate to for this spreadsheet:
+
{{RacketToImplement|spreadsheet|string->cell<br>csv->spreadsheet<br>row-count<br>row-at sheet<br>sum-row|spreadsheet}}
 +
==string->cell==
 +
(define (string->cell s)
 +
        (error 'not-yet-implemented))
 +
 
 +
* if s is the empty string, evaluate to void
 +
* if s represents a number, evaluate to that number
 +
* if s starts with "(" and ends with ")", evaluate to a form suited for eval
 +
* otherwise, evaluate to s
 +
 
 +
==csv->spreadsheet==
 +
(define (csv->spreadsheet matrix)
 +
        (error 'not-yet-implemented))
 +
 
 +
given a list of lists of strings, evaluate to a list of list of cells using [[#string->cell]] and a couple of list higher order functions.
 +
 
 +
==row-count==
 +
(define (row-count sheet)
 +
        (error 'not-yet-implemented))
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 58: Line 76:
 
|1033
 
|1033
 
|}
 
|}
 
 
{{RacketToImplement|spreadsheet|string->cell<br>csv->spreadsheet<br>row-count<br>row-at sheet<br>sum-row|spreadsheet}}
 
==string->cell==
 
(define (string->cell s)
 
        (error 'not-yet-implemented))
 
 
* if s is the empty string, evaluate to void
 
* if s represents a number, evaluate to that number
 
* if s starts with "(" and ends with ")", evaluate to a form suited for eval
 
* otherwise, evaluate to s
 
 
==csv->spreadsheet==
 
(define (csv->spreadsheet matrix)
 
        (error 'not-yet-implemented))
 
 
given a list of lists of strings, evaluate to a list of list of cells using [[#string->cell]] and a couple of list higher order functions.
 
 
==row-count==
 
(define (row-count sheet)
 
        (error 'not-yet-implemented))
 
  
 
('''row-count''' hockey-spreadsheet) evaluates to '''4'''
 
('''row-count''' hockey-spreadsheet) evaluates to '''4'''
Line 85: Line 82:
 
  (define (row-at sheet row-index)
 
  (define (row-at sheet row-index)
 
         (error 'not-yet-implemented))  
 
         (error 'not-yet-implemented))  
 +
 +
('''row-at''' hockey-spreadsheet) evaluates to '''(list "Bobby Orr" 4 1948 657 270 645)'''
 +
 
==sum-row==
 
==sum-row==
 
  (define (sum-row sheet row-index)
 
  (define (sum-row sheet row-index)
 
         (error 'not-yet-implemented))
 
         (error 'not-yet-implemented))
 +
 +
('''row-at''' hockey-spreadsheet) evaluates to '''3524'''
  
 
=Test=
 
=Test=
 
{{RacketUnitTest|spreadsheet_test|spreadsheet}}
 
{{RacketUnitTest|spreadsheet_test|spreadsheet}}

Revision as of 14:06, 30 March 2022

Motivation

Code To Use

general

void

number

string

list

Code To Implement

file: src/main/racket/spreadsheet/spreadsheet.rkt Racket-logo.svg
functions: string->cell
csv->spreadsheet
row-count
row-at sheet
sum-row

string->cell

(define (string->cell s)
       (error 'not-yet-implemented))
  • if s is the empty string, evaluate to void
  • if s represents a number, evaluate to that number
  • if s starts with "(" and ends with ")", evaluate to a form suited for eval
  • otherwise, evaluate to s

csv->spreadsheet

(define (csv->spreadsheet matrix)
       (error 'not-yet-implemented))

given a list of lists of strings, evaluate to a list of list of cells using #string->cell and a couple of list higher order functions.

row-count

(define (row-count sheet)
       (error 'not-yet-implemented))
Name Uniform Number Birth Year Games Played Goals Assists
Bobby Orr 4 1948 657 270 645
Wayne Gretzky 99 1961 1487 894 1963
Mario Lemieux 66 1965 915 690 1033

(row-count hockey-spreadsheet) evaluates to 4

row-at

(define (row-at sheet row-index)
       (error 'not-yet-implemented)) 

(row-at hockey-spreadsheet) evaluates to (list "Bobby Orr" 4 1948 657 270 645)

sum-row

(define (sum-row sheet row-index)
       (error 'not-yet-implemented))

(row-at hockey-spreadsheet) evaluates to 3524

Test

file: spreadsheet_test.rkt Racket-logo.svg Test
source folder: src/test/racket/spreadsheet

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