Difference between revisions of "Dynamic Spreadsheet Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
Line 16: Line 16:
  
 
=Code To Implement=
 
=Code To Implement=
{{RacketToImplement|spreadsheet|to-cell<br>csv->spreadsheet<br>row-count<br>row-at sheet<br>sum-row|spreadsheet}}
+
{{RacketToImplement|spreadsheet|string->cell<br>csv->spreadsheet<br>row-count<br>row-at sheet<br>sum-row|spreadsheet}}
 
==string->cell==
 
==string->cell==
  <nowiki>(define (string->cell s)
+
  (define (string->cell s)
         (error 'not-yet-implemented)) </nowiki>
+
         (error 'not-yet-implemented))
  
 
==csv->spreadsheet==
 
==csv->spreadsheet==
define a '''MACRO''' <code>thunk-that</code> which takes a parameter <code>e</code> creates thunk.  that is: wraps <code>e</code> in a zero argument function.
+
  (define (csv->spreadsheet matrix)
 
+
        (error 'not-yet-implemented))  
  (define-syntax-rule (thunk-that e)
 
    (error 'not-yet-implemented))
 
 
 
Thunks are useful for delaying the evaluation of expressions.  As such <code>thunk-that</code> must be declared as a macro and not a function.  Unlike [https://www.haskell.org/ Haskell] which has lazy evaluation, Racket (and most other languages) [https://en.wikipedia.org/wiki/Eager_evaluation eagerly evaluates] function arguments.
 
  
 
==row-count==
 
==row-count==
define a function <code>dethunk</code> which takes a thunk parameter <code>e</code> and returns the result of invoking <code>e</code>.
+
  (define (row-count sheet)
 
+
        (error 'not-yet-implemented))  
  (define (dethunk-that thunk)
 
    (error 'not-yet-implemented))
 
 
 
If thunking and expression wraps an expression in a single argument function, then de-thunking is simply calling that function.
 
 
 
If the parameter <code>thunk</code> is not a <code>thunk?</code> then <code>dethunk-that</code> should [https://docs.racket-lang.org/reference/exns.html#%28def._%28%28quote._~23~25kernel%29._raise-argument-error%29%29 raise an argument error].
 
 
 
NOTE: It may seem unnecessary to use <code>dethunk-that</code> when implementing Lab4, when you could simply (thunk)... that is "call the thunk".  Still, you are encouraged to use <code>dethunk-that</code> as a bit of verbosity can sometimes help in debugging a sea already full of parentheses.
 
  
 
==row-at==
 
==row-at==
 
+
(define (row-at sheet row-index)
 +
        (error 'not-yet-implemented))
 
==sum-row==
 
==sum-row==
define a function <code>destream</code> which takes a <code>stream</code> parameter and a pair of the next answer and the next stream.
+
  (define (sum-row sheet row-index)
 
+
        (error 'not-yet-implemented))
  (define (destream stream)
 
    (error 'not-yet-implemented))
 
  
 
=Test=
 
=Test=
 
{{RacketUnitTest|spreadsheet_test|spreadsheet}}
 
{{RacketUnitTest|spreadsheet_test|spreadsheet}}

Revision as of 05:44, 30 March 2022

Motivation

Code To Use

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))

csv->spreadsheet

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

row-count

(define (row-count sheet)
       (error 'not-yet-implemented)) 

row-at

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

sum-row

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

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.