Hi, 1) How do you change the order of a list according to some property (e.g. decreasing order)? 2) How to evaluate the following expressions? (in the same environment) (+ '1 '2) '(+ 1 3) '(a (b (c (d)))) (define x 3) 'x (define a x) 'a (define b 'x) b 'b (quote (quote a)) ''a Thanks, I'm really lost in evaluations!

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Hi, 1) How do you change the order of a list according to some property (e.g. decreasing order)? 2) How to evaluate the following expressions? (in the same environment) (+ '1 '2) '(+ 1 3) '(a (b (c (d)))) (define x 3) 'x (define a x) 'a (define b 'x) b 'b (quote (quote a)) ''a Thanks, I'm really lost in evaluations!

MIT 6.001 Structure and Interpretation of Computer Programs, Spring 2005
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

To be exact, my question is why we evaluate them the way we do? I don't get the rules of evaluation for tagged data.
what language is this?
Umm Scheme of course. That's the language of the course.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

I can't help you I don't program in that low level of a language I think Lisp is in that category as well People do consider you a major geek if you know Lisp or Scheme though. These languages are good for processing mathmatical data and maybe statistical data I can just think of easier ways to do what you want to do with higher level 5th and 6th generation languages. What hardware and O/S do you plan to run your program on ? Objective-C, JAVA, ActionScript 3.0, PHP, or Python even might be a better choice for you to learn CORE programming techniques on after u learn core you will be able to better use just about any API or programming language out the CORE doesn't really change just the methods and techniques to reach your "final output/dynamic output changes." I've wrote some extremely complex programs that only contain 6000 lines of code in ActionScript but Actionscript is dying so I plan to port all my stuff to Objective-C and Coca and run my programs on Apple/IOS devices. This is my opnion take it with a grain of salt. I will never know all there is to know about programming. I don't know what I'm doing all I know is I don't want to stop --Ozzy Osbourn
;; 1) ;; You could use sort with a comparison function. like < or >: ;; ascending: (sort '(8 5 14 7 3) <) ; '(3 5 7 8 14) ;; descending: (sort '(8 5 14 7 3) >) ; '(14 8 7 5 3) ;; When dealing with strings, use string? in place of < or >: (sort '("Ga" "Ag" "Cu" "Fe" "Xe") string?) ; '("Xe" "Ga" "Fe" "Cu" "Ag") ;; To sort a list of symbols, you can convert them to strings, then sort, ;; then convert back to symbols: (map string->symbol (sort (map symbol->string '(tau xi gamma mu rho)) string>?)) ; '(xi tau rho mu gamma) ;; There are no functions named symbol? in Racket (but there is ;; symbol=?), so you could just define them: (define (symbolstring a) (symbol->string b))) (define (symbol>? a b) (string>? (symbol->string a) (symbol->string b))) (sort '(xi tau rho mu gamma) symbol?) ; '(xi tau rho mu gamma) ;; ------------------------------------------------------- ;; 2) ;; I give the response in comment after the expression. ;; Quoted numbers are evaluated to themselves, there's no difference ;; between 2 and '2 in Scheme: (+ '1 '2) ; 3 ;; This is just quoted list, + is treated like '+ (not evaluated): '(+ 1 3) ; '(+ 1 3) ;; If you need to evaluate quoted lists: (eval '(+ 1 3)) ; 4 ;; But the first element of list must be procedure, this gives error: (eval '(4 1 3)) ; procedure application: expected procedure, given: 4 ;; Just quoted list of nested lists of symbols: '(a (b (c (d)))) ; '(a (b (c (d)))) ;; Here you bind the symbol x to 3: (define x 3) 'x ; 'x (eval 'x) ; 3 ;; Here you just copy the address of 3 and bind it to a. ;; Now both x and a point to 3 (a is not pointing to the symbol x): (define a x) 'a ; 'a a ; 3 ;; Binds b to literal symbol x, not to the cell named x (which holds 3): (define b 'x) b ; 'x 'b ; 'b ;; If you want back the value pointed by a, use eval twice: (quote (quote a)) ; ''a ''a ; ''a (eval ''a) ; 'a (eval (eval ''a)) ; 3 ;; Quoting in Scheme is good for passing around the names of bindings ;; instead of the values they point to. This is analogous to ;; quotes in written text. There's a difference between "Say your name!" ;; and "Say 'your name'!" (See lecture 3B, at 18:10): http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/3b-symbolic-differentiation-quotation/

Not the answer you are looking for?

Search for more explanations.

Ask your own question