Get Tech'Ed HomePage

Course Homepage


CSM CSCI-400

Racket - Map and Curry

(Last Mod: 17 December 2013 13:16:53 )



For this assignment you will be creating a small search facility. The data you are searching will be stored as a list of lists. The primary item in each list is an academic paper reference. Each reference will be structured as: ((title of paper) ((first author) (second author) ..) ("keywords")). The specific list you will use is provided below.

NOTE: These are not complete references, obviously, because there's no publisher, date etc.

(define articles '(
     ((Test-Driven Learning: Intrinsic Integration of Testing into the CS/SE Curriculum)
      ((David Jansen)(Hossein Saiedian))
      ("Test-driven learning" "test-driven development" "extreme programming" "pedagogy" "CS1"))
     ((Process Improvement of Peer Code Review and Behavior Analysis of its Participants)
      ((WANG Yan-qing) (LI Yi-jun) (Michael Collins) (LIU Pei-jie))
      ("peer code review" "behavior analysis" "software quality assurance" 
        "computer science education" "software engineering"))
     ((Computer Games as Motivation for Design Patterns)
      ((Paul V. Gestwicki))
      ("Design Patterns" "Games" "Pedagogy" "Java"))
     ((Killer "Killer Examples" for Design Patterns)
      ((Carl Alphonce) (Michael Caspersen) (Adrienne Decker))
      ("Object-orientation" "Design Patterns"))
     ((Test-First Java Concurrency for the Classroom)
      ((Mathias Ricken)(Robert Cartwright))
      ("CS education" "Java" "JUnit" "unit testing" "concurrent programming"
       "tools" "software engineering"))
     ((Teaching Design Patterns in CS1: a Closed Laboratory Sequence
                based on the Game of Life)
      ((Michael Wick))
      ("Design Patterns" "Game of Life" "CS1" "Laboratory"))
   ))

Step 1. A common technique in Racket programming is to create accessor functions to extract information from data stored as nested lists. You should create 3 accessor functions to extract the title, keywords and authors. For example, given one article such as '((Test-Driven Learning: Intrinsic Integration of Testing into the CS/SE Curriculum) ((David Jansen)(Hossein Saiedian)) ("Test-driven learning" "test-driven development" "extreme programming" "pedagogy" "CS1")) the function get-Authors returns the nested list of authors: ((David Jansen)(Hossein Saiedian)). See figure below. NOTE: We won't ultimately need getAuthors, but we'll write it for completeness.

Accessors
Figure 1. Accessors for data structure

Step 2. Now you will write code to search the list of articles and return a list of all articles that contain a specified keyword. See figure below.

Keyword Search
Figure 2. Example keyword searches.

Implementation Details/Requirements

The purpose of this exercise is to understand map and currying. Therefore, your solution must meet certain guidelines. You must use the map functionality to apply your search criteria to the list of articles. This is tricky, because map requires a function with just one parameter (the item from the list). As a quick review, an example of using map is shown below.

map example
Figure 3. Example map.

For our program, we want to use map with our list of articles. But we don't have a simple predicate. Instead, we have a function that takes two arguments. For instance, you might try something like:

(define (containsKeyword word paper)
    (member word (getKeywords paper)))

But there's no way to use this function with map, because it requires two arguments. You will need to use the concept of currying to build up the arguments in order to use map.

The second requirement is the "reduce" component. In the map example above, notice that map returns a list of the results of applying the predicate. When users do a search, they don't want to see a list of all items searched with a true or false beside each item. They want to see just the true items. Furthermore, they don't want to see just #t, they want to see something meaningful. In our application, we'll just show a list of titles, as shown in the figure above.

This assignment is worth 40 points. Specific requirements:

Hints

The exact structure of your program is up to you, as long as you use map and some form of currying. Here's the descriptions of the functions in one solution to the problem which you may find helpful:

Submission

Name your racket program CS400_UserID_HW_06_Part#2.rkt and include in the HW06 zip file.