Scala: how to flatten a List of a Set of filepaths -


i have list[set[path]]:
update: each path in set unique , represents particular directory location. there no duplicates. so, looking total number of path elements/

val micedata = list(set(c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test7.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test2.txt,     c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test6.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test5.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test8.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test3.txt, c:\users\lulu\documents\mice_data\data_mining_folder\apowerpoint.pptx,     c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test1.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory\test4.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test10.txt),    set(c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test6.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test3.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test4.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test70.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test8.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test5.txt, c:\users\lulu\documents\mice_data\data_mining_folder\deeplynesteddirectory\flatdirectory2\test2.txt, c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test2.txt, c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test3.txt, c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test1.txt), set(c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test80.txt, c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test7.txt, c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test40.txt, c:\users\lulu\documents\github\data_mining_folder\flatdirectory\test6.txt,     c:\users\lulu\documents\mice_data\data_mining_folder\flatdirectory\test5.txt), set(c:\users\lulu\documents\mice_data\data_mining_folder\zipfile.zip), set(c:\users\lulu\documents\mice_data\data_mining_folder\micetest.txt,c:\users\lulu\documents\mice_data\data_mining_folder\riley.jpg)) 

there 5 sets in list, each set holding path(s). total number of such paths 28, if counted correctly.

now, want find out total number of path elements across sets in list.

i have done computation in area of code upstream, curious now, , learn more scala in process.

something like:

val totalpaths = <<iterate on list , count paths>> 

i shortest, idiomatic piece of code accomplish this.

val paths = {              //gives list of paths on sets     set <- micedata     path <- set    } yield path   val totalpaths = paths.toset.size    // converting set remove duplicates if 

Comments

Popular posts from this blog

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -

How to run C# code using mono without Xamarin in Android? -