gpt4 book ai didi

scala - 是否有将 String 中的元素转换为 BigInt 的方法?

转载 作者:行者123 更新时间:2023-12-01 07:39:53 24 4
gpt4 key购买 nike

这段代码:

1234.toString.map(_.asDigit) 

返回:
scala.collection.immutable.IndexedSeq[Int] = Vector(1, 2, 3, 4)

但我需要一个 scala.collection.immutable.IndexedSeq[BigInt]
似乎没有像 asBigInt 这样的方法可以将 String 字符转换为 BigInt 。如何才能做到这一点 ?

最佳答案

1234.toString.map(_.asDigit).map(BigInt(_))

关于scala - 是否有将 String 中的元素转换为 BigInt 的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18149132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com