【发布时间】:2021-09-12 05:45:13
【问题描述】:
val filesMap = [/dir/one -> {text1.txt, text2.txt, command.txt}, /dir/two -> {text1.txt, text2.txt, command.txt}, /dir/three -> {text1.txt, text2.txt}}
val allFiles = filesMap().toList
应该解析包含command.txt 文件的目录,其余的将被忽略。从上面的/dir/three 应该被忽略。然后我需要阅读 command.txt ,其中包含如下命令 Delete: 2 将两个最旧的文件插入到 allFiles 列表中。我已经有一种读取command.txt 文件并提取所有命令的方法,它的值映射commandMap。例如commandMap 如下所示。
commandMap = {Delete -> 2, Copy -> 2, Cut -> 2}
// method that extract commands from commands.txt to the map
def readCommandFile(pathToCommand: String): Map[String, Int] ={
// som logic to extract list of commands from the text file
}
【问题讨论】:
-
@Jwvh 如果您还有其他问题,请告诉我?
标签: list scala dictionary collections functional-programming