0

In the example below, if I try to turn val x into val (x,y) IDE complains vigorously.

If I try to make the return an explicit pair for the val (p,q) assignment it get the same errors.

I do not understand where the problem is.

    val x: Pair<List<Monogram>, List<Double>> = run {
        // Computed integrated percent sorted by descending percent.
        val tot = tcC.sumOf { it.count }
        val sortedByDescendingCount = tcC.sortedByDescending { it.count }

        sortedByDescendingCount to
                sortedByDescendingCount
                    .map { it.count }
                    .runningFold(0.0) { z, x -> z + x }
                    .map { it / tot }
    }

    val (p,q) = run {
        // Computed integrated percent sorted by descending percent.
        val tot = tcC.sumOf { it.count }
        val sortedByDescendingCount = tcC.sortedByDescending { it.count }

        val integral =
                sortedByDescendingCount
                    .map { it.count }
                    .runningFold(0.0) { z, x -> z + x }
                    .map { it / tot }
        Pair(sortedByDescendingCount,integral)
    }

The IDE is

Android Studio Otter | 2025.2.1 Patch 1
Build #AI-252.25557.131.2521.14432022, built on November 13, 2025
Runtime version: 21.0.8+-14196175-b1038.72 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.X11.XToolkit
Linux 6.14.0-36-generic
Ubuntu 24.04.3 LTS; glibc: 2.39
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 4096M
Cores: 24
Registry:
  debugger.watches.in.variables=false
  ide.experimental.ui=true
Non-Bundled Plugins:
  com.fwdekker.randomness (3.4.2)
  String Manipulation (9.16.0)
  com.github.marcopla99.cleancoderearranger (1.0.0)
Current Desktop: ubuntu:GNOME

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.