**Challenge yourself-old**
Realizado por Valentina Vanegas para la Clase de Unidades Semanticas.
Challenge yourself Ejercicios tomados del libro Learning Object-Oriented Programming, Design with TDD in Pharo For each of the expressions below, fill in the answers: What is the receiver object? What is the message selector? What is/are the argument (s)? What is the result returned by this expression execution?
receiver: 3 selector: + arguments: 4 result: 7
Esa me resulto sencilla, pero a medida que avanzamos es un poco más comlejo identificar ¿Qué es que?
receiver: Date selector: Today arguments: result: La fecha de hoy
Continuemos con: #('' 'World') at: 1 put: 'Hello'
receiver: #('' 'World') selector: at: 1 put: arguments: ? result: ?
receiver: #(1 22 333) selector: at: arguments: 2 result: 22
receiver: #(2 33-4 67) selector: collect arguments: at: [ :each | each abs ] result: #(2 33-4 67)
receiver: 25 selector: @ arguments: 50 result: (25@50)
receiver: SmallInteger selector: maxVal arguments: result:
receiver: #(a b c d e f) selector: includesAll: arguments: #(f d b) result: true
receiver: true selector: arguments: false result: true
Correcciones aplicadas después de la retroalimentación del ejercicio receiver: Poitn selector: Selector arguments: result:
receiver: = 4 selector: = selectors arguments: = between: result: = true
4.2 Challenge: Literal objects What kind of object does the following literal expressions refer to? It is the same as asking what is the result of sending the class message to such expressions.
Tipo de objeto: números
Tipo de objeto: simbolo
Tipo de objeto: números
Tipo de objeto: Cadenas
Tipo de objeto: Cadenas
Tipo de objeto: Caráctares
Tipo de objeto: Caráctares
4.3 Challenge: Kind of messages Examine the following messages and report if the message is unary, binary or keyword-based.
Unario
En esta parte me genera un error. Undeclared temp: browser Tipo: Unario
Keyword
Keyword
Binario
Unario
Error. Tipo: Keyword
4.4 Challenge: Results Examine the following expressions. What is the value returned by the execution of the following expressions? (valor devuelto)
-2
2
32
Second
an Array [4 items] (491009)
5
-32
true
4.5 Challenge: unneeded parentheses Putting more parentheses than necessary is a good way to get started. Such practice however leads to less readable expressions. Rewrite the following expressions using the least number of parentheses.
x between: (pt1 x and: pt2 y)
(a b c d e f asSet) intersection: #(f d b asSet)
(x isZero ifTrue: [....] x includes: y) ifTrue: [....]
OrderedCollection new add: 56; add: 33; yourself
( 3 + 4 * 2 * 2 + 2 * 3 )
Integer primesUpTo: 64 sum