遍历数组提取List[Int]
def toFlatMap(input:List[Any],result:List[Int]):List[Int]=input match{
case h::t=>h match {case e:Int=>toFlatMap(t,e::result)
case x:List[Any] => toFlatMap(t,toFlatMap(x,result))
case _=>toFlatMap(t,result)}
case Nil=>result
case _=> result
} val myList=List("a",List("a,",1000,2000),11,2,3,4,"abc",5,List(6,List(100,200),2,1).reverse,"a")
print(toFlatMap(myList,List[Int]()).reverse)
遍历数组提取List[Int]的更多相关文章
- C#遍历数组
Eg: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...
- foreach遍历数组、数组的转置与方阵的迹
public class Copy1 { public static void main(String[] args) { array1(); //如果不初始化元素,默认为0 int [][] a = ...
- 廖雪峰Java1-4数组操作-1遍历数组
1.遍历数组 for循环通过下标遍历数组 for each直接遍历数组所有元素 int[] ns1 = {1, 34, 9, 16, 25}; for(int i = 0;i<ns1.lengt ...
- C# foreach 循环遍历数组
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- JavaScript的使用以及JS常用函数(JS 遍历数组和集合)
JavaScript入门 学习总结 1. 什么是 JavaScript 2. JavaScript 的特点 3. JS的使用 编写位置 基本语法 变量 打印变量 数据类型 innerHTML和inne ...
- *使用while循环遍历数组创建索引和自增索引值
package com.chongrui.test;/* *使用while循环遍历数组 * * * */public class test { public static void main ...
- 以forin的方式遍历数组时进行删除操作的注意点
今天在修改某项需求的时候,需要在遍历的时候将匹配项移除掉,采用的时forin的方式遍历,然后运行的时候却crash掉了 for (NSString*str in self.btnArray) { if ...
- IOS开发_中遍历数组的方法及比较
数组,做为一种常用的数据类型,频繁出现在编码中,其中肯定少不了对数组的遍历,本博文对数组遍历,进行一下自己的归纳,如果是大牛,一笑而过就好,互相学习,欢迎指正. 话不多说直接进入主题 首先创建一个数组 ...
- 使用for循环遍历数组
package review20140419;/* * 遍历数组 */public abstract class Test1 { //程序入口 public static void mai ...
随机推荐
- Minikube安装
参考 https://blog.csdn.net/liumiaocn/article/details/52041726?locationNum=4&fps=1 中文社区API http://d ...
- Day5 - B - Wireless Network POJ - 2236
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wi ...
- python笔记10
今日内容 参数 作用域 函数嵌套 知识点回顾 函数基本结果 def func(name,age,email): # 函数体(保持缩进一致) a = 123 print(a) return 1111#函 ...
- Python中pandas透视表pivot_table功能详解(非常简单易懂)
一文看懂pandas的透视表pivot_table 一.概述 1.1 什么是透视表? 透视表是一种可以对数据动态排布并且分类汇总的表格格式.或许大多数人都在Excel使用过数据透视表,也体会到它的强大 ...
- python scipy优化器模块(optimize)
pyhton数据处理与分析之scipy优化器及不同函数求根 1.Scipy的优化器模块optimize可以用来求取不同函数在多个约束条件下的最优化问题,也可以用来求取函数在某一点附近的根和对应的函数值 ...
- 易语言加壳SDK(宏标记)
转载 http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece76310508c31490797634b87834e29938448e435061 ...
- Python 编写代码 检查是否遵循PEP 8标准
实际上并非必须遵守PEP 8,但是它已经成为一个默认的.约定俗成的规则,可以使代码风格更统一,提高可读性. 由于最近一直在学习Ubuntu,因此此处仍然以Ubuntu为例,介绍一下规则检查工具,它能帮 ...
- Web基础之Spring IoC
Spring之IoC 概念 IoC:Inversion of Control,中文通常翻译为"控制反转",它还有一个别名叫做依赖注入(Dependency Injection) ...
- VMware CentOS网络配置
- 安装python包的两种方法
1.在 anaconda 环境中安装包 selenium conda install selenium 2.python 下安装包 selenium pip install selenium 3.测试 ...