Sunday, 15 February 2015

scheme - flipping strings upside down racket -



scheme - flipping strings upside down racket -

this question has reply here:

upside downwards text 2 answers

i got letters turn upside down. p d can't seem string of words turn upside down. house upside downwards ǝsnoɥ. help appreciated. done. using origin pupil list abbreviations.

#;(first (first l2)) #;(first (rest l2)) #;(first (rest (first l2))) (define (helper character list) (cond [(string=? character (first (first list))) (first (rest (first list)))] [else (helper character (rest list))])) (check-expect (helper "p" table-1) "d") (check-expect (helper "t" table-1) "ʇ") ;;_______________________________________________________________________________ (define (upside-down string) (upside-down "cat")

a couple of comments on helper procedure:

you should add together status case when character not in list - if happens, homecoming same character. otherwise, error occur the parameter should not named list, that's built-in procedure , it's bad practice overwrite it test throughly before proceeding.

once that's sorted out, here's how implement upside-down, fill-in blanks:

(define (upside-down str) (<???> ; finally, opposite of explode on list (map (lambda (c) ; map on each of characters (<???> <???> <???>)) ; phone call helper on character (<???> (<???> str))))) ; reverse exploded string

if you're not allowed utilize map or lambda, implement convert procedure iterates on each of characters in string , applies helper on each one, returning list result of applying - basically, implement own map applies helper each element in input list:

(define (convert lst) <???>) (convert '("c" "a" "t")) => '("ɔ" "ɐ" "ʇ")

now can write upside-down using convert:

(define (upside-down str) (<???> ; finally, opposite of explode on list (convert ; utilize our shiny new procedure (<???> (<???> str))))) ; reverse exploded string

scheme racket

No comments:

Post a Comment