id stringlengths 16 145 | text stringlengths 1 179k | title stringclasses 1
value |
|---|---|---|
kotlin_ObservableProperty_delegates/8836_143_0.txt | Assignees
No one assigned | |
kotlin_ObservableProperty_delegates/7_59_0.txt | Your method must not do extra work by actually sorting the collection. It
should merely check if the elements are already sorted.
With clever use of the collections methods from this chapter and earlier ones,
you can solve the assignment in a single, short line of code. | |
kotlin_ObservableProperty_delegates/8836_78_0.txt | Copy link
### | |
kotlin_ObservableProperty_delegates/8836_46_0.txt | stale bot added the stale label Sep 4, 2020
Copy link | |
kotlin_ObservableProperty_delegates/showthread.php3_40_0.txt | May 2009
Location
Boston
Posts | |
kotlin_ObservableProperty_delegates/8_3_0.txt | * Skip course navigation
* #### Language
* Change language
* suomi
* Language
* suomi | |
kotlin_ObservableProperty_delegates/8836_64_0.txt | Sorry, something went wrong.
Copy link | |
kotlin_ObservableProperty_delegates/8836_10_0.txt | Collaborate outside of code
Explore | |
kotlin_ObservableProperty_delegates/8_102_0.txt | The ` contains ` method tells us if a given key is present in the map. In the
example below, ` "tapiiri" ` is present in the dictionary whereas ` "laama"
` , which we just removed, is not.
finnishToEnglish.contains("tapiiri")res30: Boolean = true
finnishToEnglish.contains("laama")res31: Boolean = f... | |
kotlin_ObservableProperty_delegates/7_40_0.txt | ### Mini-assignment: dividing a collection
Go to package ` o1.people ` in module Miscellaneous and find ` YoungAndOldApp
` . The comments in this app object explain how the program should work.
Implement the missing parts of the program. Use one of the methods just
introduced. | |
kotlin_ObservableProperty_delegates/7_138_0.txt |
finToEng.get("Mikki-Hiiri")res40: String = None
Often, you’ll do fine calling ` get ` and using the ` Option ` it returns.
But depending on what you’re trying to achieve, there may be better
alternatives. | |
kotlin_ObservableProperty_delegates/8836_98_0.txt | this is still an issue. @easazade how did you resolve this?
It happens only in release mode and to less than 5% of users.
---
All reactions
Sorry, something went wrong. | |
kotlin_ObservableProperty_delegates/7_62_0.txt | You may find the methods ` zip ` , ` tail ` , and ` forall ` useful.
(Alternatively, you could try using the ` sliding ` method introduced in 7.1
’s ` drySpell ` assignment.)
You can use ` forall ` to check whether it’s true, for each pair of
consecutive elements, that they are in the right order. The auxiliary... | |
kotlin_ObservableProperty_delegates/8_52_0.txt | With clever use of the collections methods from this chapter and earlier ones,
you can solve the assignment in a single, short line of code.
Write your code in ` misc.scala ` again. | |
kotlin_ObservableProperty_delegates/8836_13_0.txt | By Solution
* CI/CD & Automation
* DevOps
* DevSecOps | |
kotlin_ObservableProperty_delegates/8836_83_0.txt | Copy link
### | |
kotlin_ObservableProperty_delegates/8_25_0.txt | The first member of the pair has the name ` _1 ` . (One, not zero!) The
second member is ` _2 ` .
Here, the underscore doesn’t have any special meaning. It’s simply a part of a
method’s name. In Scala, like in many other languages, the name of a method
can’t start with a digit; the underscores have been used for tha... | |
kotlin_ObservableProperty_delegates/8_64_0.txt |
val index = searchTerms.indexOf("tapiiri")index: Int = 2
englishTranslation(index)res14: String = tapir
englishTranslation(searchTerms.indexOf("koira"))res15: String = puppy
We can also update the dictionary by replacing an element. The Finnish word
“koira” is better translated as “dog” than... | |
kotlin_ObservableProperty_delegates/ObservableProperty_4_0.txt | [ ](https://kotlinlang.org) [ v1.9.23
](https://github.com/JetBrains/kotlin/releases/tag/v1.9.23)
* Solutions
* [ Multiplatform ](/lp/mobile/)
* [ Server-side ](/lp/server-side/)
* [ Data science ](/docs/data-science-overview.html)
* [ Android ](/docs/android-overview.html)
* [ Docs ](/docs/home.h... | |
kotlin_ObservableProperty_delegates/showthread.php3_48_0.txt | * * *
Quick Navigation C++ (Non Visual C++ Issues) Top | |
kotlin_ObservableProperty_delegates/8836_115_0.txt | It's still appearing in release mode any solution for this ??
---
All reactions
Sorry, something went wrong. | |
kotlin_ObservableProperty_delegates/7_65_0.txt | Does that mean a tuple is a collection, like buffers and vectors are? Not
quite.
First of all, tuples and collections have different purposes. Tuples tend to
be most useful when: 1) there is a small, constant number of members (e.g.,
only two), and 2) each member has a meaning separate from the others (e.g.,
one signi... | |
kotlin_ObservableProperty_delegates/8836_59_0.txt | Copy link
Author | |
kotlin_ObservableProperty_delegates/8836_68_0.txt | Copy link
### | |
kotlin_ObservableProperty_delegates/7_35_0.txt | None of the above. It’s not possible to know what happens without knowing the
two original variables’ values.
### Dividing collections | |
kotlin_ObservableProperty_delegates/showthread.php3_8_0.txt | 364
## map name does not name a type error | |
kotlin_ObservableProperty_delegates/7_92_0.txt | However, when defining key–value pairs, it’s common to use another notation.
This other notation highlights that each key “points at” the corresponding
value. The following code produces precisely the same outcome as the code
above:
"koira" -> "dog"res22: (String, String) = (koira,dog)
| |
kotlin_ObservableProperty_delegates/8_47_0.txt |
for (pair <- species.zipWithIndex) {
println(pair._1 + " is at index #" + pair._2)
}llama is at index #0
alpaca is at index #1
vicuña is at index #2
for ((element, index) <- species.zipWithIndex) {
println(element + " is at index #" + index)
}llama is at index #0
alpaca... | |
kotlin_ObservableProperty_delegates/7_21_0.txt | Let’s have a look at pairs in general before we return to minutes and seconds.
## Pairs | |
kotlin_ObservableProperty_delegates/8836_67_0.txt | stale bot added the stale label Oct 10, 2020
stale bot closed this as completed Oct 17, 2020 | |
kotlin_ObservableProperty_delegates/8836_65_0.txt | ###
stale bot commented Oct 10, 2020 | |
kotlin_ObservableProperty_delegates/7_83_0.txt | ` indexOf ` will then return -1 and we end up with a runtime error if we
access a negative index of ` englishTranslation ` . We could work around that
with an ´if`, but that’s additional work and we might forget to do so.
(Fourth, if we had lots of words in the dictionary, we might also wish for
improved efficiency.... | |
kotlin_ObservableProperty_delegates/showthread.php3_2_0.txt | * * Forum
* Visual C++ & C++ Programming
* C++ (Non Visual C++ Issues)
* map name does not name a type error
* * * | |
kotlin_ObservableProperty_delegates/8_67_0.txt | * We used two separate buffers for keys and values even though we conceive of the dictionary as a single entity.
* It feels unnecessary to have to mess about with indices in order to look up a word. Nobody really cares which index the source or target word has in the buffer.
* What if the key is not found?
... | |
kotlin_ObservableProperty_delegates/showthread.php3_58_0.txt | All times are GMT -5. The time now is 10:27 PM .
Copyright TechnologyAdvice | |
kotlin_ObservableProperty_delegates/8_36_0.txt | Naturally, you can also define a function that takes a pair as a parameter.
The example function below determines whether a given pair of numbers is “in
order”, that is, whether the pair’s first member is no greater than the
second.
def isInOrder(pairOfNumbers: (Int, Int)) = pairOfNumbers._1 <= pairOfNum... | |
kotlin_ObservableProperty_delegates/7_172_0.txt | * Multiple data items — even items of different types — can be combined into a tuple. A pair is a tuple with two members.
* Maps are a tremendously useful and common sort of collection. A map contains key–value pairs. It differs from numerically indexed collections in that: | |
kotlin_ObservableProperty_delegates/8836_140_0.txt | Copy link
### | |
kotlin_ObservableProperty_delegates/showthread.php3_10_0.txt | Reply With Quote
* * * | |
kotlin_ObservableProperty_delegates/8_126_0.txt | ` get ` — good or bad?
So, the ` get ` method of ` Map ` objects is good? Even though the ` get `
method of ` Option ` objects is bad (as discussed in the optional sections of
4.4 and 8.2 )? | |
kotlin_ObservableProperty_delegates/8_120_0.txt | One way to deal with missing values is to use ` getOrElse ` instead. This
method greatly resembles the method of the same name on ` Option ` s (Chapter
4.3 ), which essentially tells an ` Option ` object “Give me the value you
contain or, failing that, use this value instead.” The ` getOrElse ` method
of a ` Map ... | |
kotlin_ObservableProperty_delegates/7_104_0.txt |
import scala.collection.mutable.Map
As you’ll know by now, objects can be mutable or immutable . Since Scala
is designed to support different styles of programming, its standard API comes
with two different ` Map ` classes, one for mutable maps and one for
immutable ones. For now, we’ll mostly use m... | |
kotlin_ObservableProperty_delegates/7_14_0.txt | Points Available: B25.
Related Modules: Miscellaneous . | |
kotlin_ObservableProperty_delegates/8_21_0.txt | Let’s have a look at pairs in general before we return to minutes and seconds.
## Pairs | |
kotlin_ObservableProperty_delegates/8_127_0.txt | Yes, that’s right.
### Practice on ` get ` , ` apply ` , and ` getOrElse ` | |
kotlin_ObservableProperty_delegates/showthread.php3_56_0.txt | * * Windows App Gallery
See the Windows 8.x apps we've spotlighted or submit your own app to the
gallery!
| |
kotlin_ObservableProperty_delegates/7_191_0.txt | « Chapter 9.1: Robots and Conditional Looping Course materials Chapter 9.3:
Interactive Fiction and Code Quality »
* Privacy Notice
* Accessibility Statement
* Support
* Feedback
* A+ v1.23.0 | |
kotlin_ObservableProperty_delegates/8_2_0.txt | Toggle navigation
* Log in | |
kotlin_ObservableProperty_delegates/7_160_0.txt | Don’t make any other changes to ` Society ` . Don’t edit ` Member ` .
Hint: there is a method that supplies a simple solution. It was introduced in
a recent chapter. | |
kotlin_ObservableProperty_delegates/8836_1_0.txt | Toggle navigation
Sign in | |
kotlin_ObservableProperty_delegates/7_117_0.txt | ### Removing a key–value pair
Here’s one way to remove a pair: | |
kotlin_ObservableProperty_delegates/7_12_0.txt | Questions Answered: Can a function return two values? How can I easily find
an object that corresponds to another object (e.g., the English translation of
a Finnish word)? What’s an easy and efficient way to find elements in a
collection when I have a search key of some sort (e.g., to find a student
object among many ... | |
kotlin_ObservableProperty_delegates/8836_60_0.txt | ###
easazade commented Sep 5, 2020 | |
kotlin_ObservableProperty_delegates/7_186_0.txt | The pedagogy of using O1Library for simple graphical programming (such as `
Pic ` ) is inspired by the textbooks How to Design Programs by Flatt,
Felleisen, Findler, and Krishnamurthi and Picturing Programs by Stephen
Bloch.
The course platform A+ was originally created at Aalto’s LeTech research
group as a stu... | |
kotlin_ObservableProperty_delegates/7_111_0.txt | If the key was present in the map, we get a ` Some ` that holds the
corresponding value. If not, we get ` None ` .
### Replacing a value | |
kotlin_ObservableProperty_delegates/7_41_0.txt | A+ presents the exercise submission form here.
### Zipping collections together | |
kotlin_ObservableProperty_delegates/8836_38_0.txt | ###
easazade commented Aug 4, 2020 • | |
kotlin_ObservableProperty_delegates/7_102_0.txt | Since the idea is to visually suggest an arrow, the operator notation is
understandably much more common here.
## Maps in Scala: Class ` Map ` | |
kotlin_ObservableProperty_delegates/8836_105_0.txt | ###
FDuhen commented Oct 24, 2022 • | |
kotlin_ObservableProperty_delegates/8_22_0.txt | ### Basic use of pairs in Scala
You can form a pair with brackets and a comma, as shown here: | |
kotlin_ObservableProperty_delegates/8_27_0.txt | It’s easy to copy the two members of a pair into two separate variables. Just
use brackets:
val (name, shoeSize) = nameAndShoeSizename: String = Juha
shoeSize: Int = 43
| |
kotlin_ObservableProperty_delegates/8_0_0.txt | Skip main navigation
A+ | |
kotlin_ObservableProperty_delegates/8_113_0.txt | A frequently asked question: how can you construct a ` Map ` whose keys are
the values of an existing ` Map ` and whose values are the original ` Map
` ’s keys?
In simple cases, that’s easy enough to do, especially if you use the ` swap `
method that’s available on pairs and works like this: | |
kotlin_ObservableProperty_delegates/delegates_2_0.txt | [ ](https://kotlinlang.org) [ v1.9.23
](https://github.com/JetBrains/kotlin/releases/tag/v1.9.23)
* Solutions
* [ Multiplatform ](/lp/mobile/)
* [ Server-side ](/lp/server-side/)
* [ Data science ](/docs/data-science-overview.html)
* [ Android ](/docs/android-overview.html)
* [ Docs ](/docs/home.h... | |
kotlin_ObservableProperty_delegates/7_58_0.txt | Write a function ` isAscending ` that takes in a vector of integers and
reports whether those integers are in ascending order. Here are some examples:
isAscending(Vector(-10, 1, 5, 10))res11: Boolean = true
isAscending(Vector(-10, 1, 5, 5, 10))res12: Boolean = true
isAscending(Vector(-10, 1, 5, ... | |
kotlin_ObservableProperty_delegates/showthread.php3_50_0.txt | #### Posting Permissions
* You may not post new threads
* You may not post replies
* You may not post attachments
* You may not edit your posts
* | |
kotlin_ObservableProperty_delegates/7_101_0.txt | We could have used the dot notation. These two expressions are equivalent:
"polvi".->("knee")res26: (String, String) = (polvi,knee)
"polvi" -> "knee"res27: (String, String) = (polvi,knee)
| |
kotlin_ObservableProperty_delegates/showthread.php3_37_0.txt | > Can Cl and Br be shortened to a single unique char?
> All advice is offered in good faith only. All my code is tested (unless
> stated explicitly otherwise) with the latest version of Microsoft Visual
> Studio (using the supported features of the latest standard) and is offered
> as examples only - not as production... | |
kotlin_ObservableProperty_delegates/showthread.php3_17_0.txt | Germany
Posts
1,158 | |
kotlin_ObservableProperty_delegates/8836_61_0.txt | i guess it could be a cache problem since whenever i quit app and launch it
again. everything works fine.
---
All reactions
Sorry, something went wrong. | |
kotlin_ObservableProperty_delegates/8_76_0.txt |
"koira" -> "dog"res18: (String, String) = (koira,dog)
The ` -> ` arrow defines a pair. (Note: it’s ` -> ` , not ` => ` , which we
have used in function types and ` case ` branches.) | |
kotlin_ObservableProperty_delegates/8836_114_0.txt | ###
Mashood97 commented Nov 22, 2022 | |
kotlin_ObservableProperty_delegates/8836_107_0.txt | All reactions
* 👍 4 reactions | |
kotlin_ObservableProperty_delegates/showthread.php3_53_0.txt |
Featured | |
kotlin_ObservableProperty_delegates/8836_150_0.txt | ### Footer navigation
* Terms
* Privacy
* Security
* Status
* Docs
* Contact
* Manage cookies
* Do not share my personal information | |
kotlin_ObservableProperty_delegates/7_122_0.txt | Yes, it searches the values as well.
No, it searches only the keys. | |
kotlin_ObservableProperty_delegates/8_82_0.txt | The second string is passed as a parameter to the method. In the operator
notation, we can omit the brackets around the parameter.
The method returns a pair that comprises the target object and the parameter
object. | |
kotlin_ObservableProperty_delegates/8_74_0.txt | ## But Before We Get to ` Map ` s: Key–Value Pairs
Here’s some Scala code that defines a key–value pair. This is just a regular
pair that happens to contain data that we intend to use as a key and a value. | |
kotlin_ObservableProperty_delegates/8_10_0.txt | Voit vaihtaa kieltä A+:n valikon yläreunassa olevasta painikkeesta. Tai tästä:
Vaihda suomeksi .
| |
kotlin_ObservableProperty_delegates/7_114_0.txt | There are a number of ways to add a key–value pair to a mutable map. One of
them is to assign a value to a previously unused key:
finnishToEnglish("hiiri") = "mouse" | |
kotlin_ObservableProperty_delegates/8_34_0.txt | We get a new variable whose value is a pair and whose members are equal to the
values stored in ` gretel ` and ` hansel ` .
None of the above. It’s not possible to know what happens without knowing the
two original variables’ shared data type. | |
kotlin_ObservableProperty_delegates/7_113_0.txt | Remember: the keys of a map are unique. A map cannot contain multiple
key–value pairs whose keys are equal. So what happens above is that the pair `
"koira" -> "puppy" ` is replaced by the pair ` "koira" -> "dog" ` .
### Adding a key–value pair | |
kotlin_ObservableProperty_delegates/8_28_0.txt | ### A minute assignment
Implement the ` toMinsAndSecs ` function we contemplated earlier. It should
work like this: | |
kotlin_ObservableProperty_delegates/8_29_0.txt |
toMinsAndSecs(187)res4: (Int, Int) = (3,7)
val (min, s) = toMinsAndSecs(200)min: Int = 3
s: Int = 20
Write your solution in ` o1/misc.scala ` in module Miscellaneous. | |
kotlin_ObservableProperty_delegates/showthread.php3_35_0.txt | Dec 2012
Location
England
Posts | |
kotlin_ObservableProperty_delegates/8_91_0.txt | It’s simple to fetch a value that matches a key:
finnishToEnglish.get("kissa")res23: Option[String] = Some(cat)
finnishToEnglish.get("Mikki-Hiiri")res24: Option[String] = None
| |
kotlin_ObservableProperty_delegates/8_56_0.txt | ### Pairs are tuples
A pair is a two-membered tuple ( monikko ). A tuple may have more members
than just two: | |
kotlin_ObservableProperty_delegates/8836_12_0.txt | For
* Enterprise
* Teams
* Startups
* Education | |
kotlin_ObservableProperty_delegates/8_50_0.txt |
heightsAndSpecies.unzipres8: (Vector[Int], Vector[String]) = (Vector(180, 80, 60),Vector(llama, alpaca, vicuña))
### Mini-assignment: ` isAscending ` | |
kotlin_ObservableProperty_delegates/7_52_0.txt | A similar principle is at work in the following example.
### Combining pairs with higher-order functions | |
kotlin_ObservableProperty_delegates/8_40_0.txt | ` splitAt ` takes in a number that indicates a position in the collection.
The first member of the returned pair lists all the elements that are located
before the indicated position in the original collection. The second member
lists the rest of the elements. | |
kotlin_ObservableProperty_delegates/showthread.php3_47_0.txt | > All advice is offered in good faith only. All my code is tested (unless
> stated explicitly otherwise) with the latest version of Microsoft Visual
> Studio (using the supported features of the latest standard) and is offered
> as examples only - not as production quality. I cannot offer advice
> regarding any other c... | |
kotlin_ObservableProperty_delegates/8_45_0.txt | Collections have a handy method named ` zipWithIndex ` . It forms a new
collection where each element is the original element paired with its index:
val species = Vector("llama", "alpaca", "vicuña")species: Vector[String] = Vector(llama, alpaca, vicuña)
species.zipWithIndexres7: Vector[(String, Int)... | |
kotlin_ObservableProperty_delegates/7_179_0.txt | somewhat disagree
fully disagree | |
kotlin_ObservableProperty_delegates/8_57_0.txt |
("This tuple has four members of different types.", 100, 3.14159, false)res13: (String, Int, Double, Boolean) = (This tuple has four members of different types.,100,3.14159,false)
Does that mean a tuple is a collection, like buffers and vectors are? Not
quite. | |
kotlin_ObservableProperty_delegates/8_37_0.txt | Usage example:
val myPair = (10, 20)myPair: (Int, Int) = (10,20)
isInOrder(myPair)res5: Boolean = true
| |
kotlin_ObservableProperty_delegates/7_89_0.txt | The familiar ` map ` -that-is-a-method takes an existing collection and uses
its elements to generate another. The parameter function of ` map ` defines a
mapping from the original elements to the generated elements.
A ` Map ` object — a map-that-is-a-collection — is a collection of keys and
values; it stores a map... | |
kotlin_ObservableProperty_delegates/7_174_0.txt | * you commonly use a map via keys: it’s easy and efficient to fetch a value that corresponds to a key.
* The Scala API gives us a ` Map ` class with useful methods. | |
kotlin_ObservableProperty_delegates/7_173_0.txt | * a map’s elements don’t have an order determined by running numbers;
* nor can you use indices to select a particular element of a map. Instead, | |
kotlin_ObservableProperty_delegates/8836_7_0.txt | Write better code with AI
* Code review |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.