[racket] (no subject)

From: Cody Goodman (codygman.consulting at gmail.com)
Date: Mon May 13 05:45:32 EDT 2013

Hello, can anyone offer an idiom/thinking process/approach critique on my
code below? I'm new to racket and trying to program in racket, not program
python in racket syntax ;)

#lang racket
(require json)
(require net/url)

(define data-set
  (let* (
         ;; Turn url into a net/url-struct so you can allow a different
search query as well as other customizations
         ;; easily.
         [api-url (string->url "
         ;; figure out how to use call/input url
         [in (get-pure-port api-url #:redirections 2)]
         [json-blob (read-json in)])
    (close-input-port in)

(struct movie (title price link))
(define movies (hash-ref (hash-ref data-set 'feed) 'entry))

(define (make-movie movie-result)
  (let* (
         [title (hash-ref (hash-ref movie-result 'title) '$t)]
         [price (with-handlers ([exn:fail? (lambda (exn) 0)])
                  (hash-ref (car (hash-ref (hash-ref movie-result
'media$group) 'media$price)) 'price))]
         [link (hash-ref (car (hash-ref movie-result 'link)) 'href)]
         [movie-to-return (movie title price link)])

(define (make-movie-listing movie)
  (list (movie-title movie) (movie-price movie) (movie-link movie)))

(define (show-all-movie-listings)
(map make-movie-listing (map make-movie movies)))

(define (get-relevant-movie-listings movie)
  ;; TODO: Figure out how to pass paramters into a function with map. Maybe
    [(string=? (movie-title movie) "Inception") movie]))

;; TODO: Make this into a function after figuring out how to pass
parameters into a function with map.
(define find-movie
  (car(map get-relevant-movie-listings (map make-movie movies))))

(define inception-movie find-movie)
(movie-title inception-movie)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130513/66871af1/attachment.html>

Posted on the users mailing list.