gpt4 book ai didi

ruby - Ruby 的 Dir.glob() 最简洁的 Clojure 等价物是什么?

转载 作者:数据小太阳 更新时间:2023-10-29 06:41:30 25 4
gpt4 key购买 nike

在 Clojure 中做这样的事情最简单的方法是什么?

require 'csv'
Dir["data/*.csv"].each do |file|
File.readlines(file).each do |line|
x, y, z = *CSV.parse_line(line)
# process this data
end
end

最佳答案

这是我见过的最短的:

(require '[clojure.java.io :as io])

(filter #(.endsWith (.getName %) ".csv") (file-seq (io/file dir))))

来自 https://github.com/brentonashworth/one/blob/master/src/lib/clj/one/reload.clj#L28

关于ruby - Ruby 的 Dir.glob() 最简洁的 Clojure 等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5019978/

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