Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在clojure中访问atom元素 (def输入(atom[ #{ [ {:站点id 1} {:两个uncl[[27 4]“湿度”]} {:own unc | other conf[[30 1]“湿度”]} {:其他站点UNCL 2500} {:其他站点配置2500} [ {:站点id 0} {:uncl[[21]“温度”]} {:own unconf | other conf[[22 0]“Temperature”]} {:其他站点uncl 3} {:其他站点配置1} ] ] }:还有别的吗 ]))_Clojure - Fatal编程技术网

如何在clojure中访问atom元素 (def输入(atom[ #{ [ {:站点id 1} {:两个uncl[[27 4]“湿度”]} {:own unc | other conf[[30 1]“湿度”]} {:其他站点UNCL 2500} {:其他站点配置2500} [ {:站点id 0} {:uncl[[21]“温度”]} {:own unconf | other conf[[22 0]“Temperature”]} {:其他站点uncl 3} {:其他站点配置1} ] ] }:还有别的吗 ]))

如何在clojure中访问atom元素 (def输入(atom[ #{ [ {:站点id 1} {:两个uncl[[27 4]“湿度”]} {:own unc | other conf[[30 1]“湿度”]} {:其他站点UNCL 2500} {:其他站点配置2500} [ {:站点id 0} {:uncl[[21]“温度”]} {:own unconf | other conf[[22 0]“Temperature”]} {:其他站点uncl 3} {:其他站点配置1} ] ] }:还有别的吗 ])),clojure,Clojure,我想从这个atom地图访问站点id 我正在使用下面的代码,但没有得到输出 (->> @input (map #(:site-id %)) (into []) 这种数据结构非常奇怪。是的 一个原子,包含 向量,包含 一套,包含 向量,包含 一堆单键映射,然后 另一个向量,包含 一组单键映射 等等,大概是吧 如果我们允许:something-other是其他的东西,那么它应该是有用的: 一个原子,包含 向量,包含 一套,包含 一堆地图 因此: 如果是这样,那

我想从这个atom地图访问站点id

我正在使用下面的代码,但没有得到输出

(->> @input
     (map #(:site-id %))
     (into [])
这种数据结构非常奇怪。是的

  • 一个原子,包含
  • 向量,包含
  • 一套,包含
  • 向量,包含
  • 一堆单键映射,然后
  • 另一个向量,包含
  • 一组单键映射
  • 等等,大概是吧
如果我们允许
:something-other
是其他的东西,那么它应该是有用的:

  • 一个原子,包含
  • 向量,包含
  • 一套,包含
  • 一堆地图
因此:

如果是这样,那么

(->> @input
     first
     (mapv :site-id))

可以。

您确定您的输入正确吗?这些嵌套列表?现在使用嵌套,要获得all:site id,您需要使用tree seq或类似的方法来遍历层次结构。我会仔细检查一下,这是否真的是你有意设计的数据结构,而不仅仅是一些快乐的小意外。事实上,输入是由我通过合并两个地图生成的。我已经将输入更改为--#atom[{{[{:site id(2)}{:tware unci[[817.9834427857821 229.6681612525713]“CO2”}{:own unci other conf[[697.2878144908756 123.50870427784022]“CO2”}{:其他站点UNCI 161/1250}{:其他站点配置1089/1250}][{:站点id(0)}{:两个UNCI[[21.69303694863922 0.6983724350490743]“温度”}{:自身UNCI}其他配置[[21.306901268115865 0.6576811158640271]“温度”}{请参见:其他站点UNCI 1323/10000}其他站点UNCI/10000}这更好了,但仍然很奇怪。我不知道你是如何得到这些单键映射向量的。我认为这就是你的实际问题所在。那么,我如何才能在clojure中创建这样的结构,因为我是clojure新手。我计算了所有这些值。我的输入是一个原子,它存储了大约两个具有相同属性的不同元素的详细信息特征如:站点id等。我创建了两个地图并将它们加入到输入中。我如何才能获得上面代码中所示的单个地图的输出我不知道您的实际输入是什么样子。也许可以修改问题,或者创建一个新的问题?
(def input
  (atom [#{{:site-id 1
            :both-unconf [[27 4] "Humidity"]
            :own-unconf|other-conf [[30 1] "Humidity"]
            :other-site-unconf 2500
            :other-site-conf 2500} 
           {:site-id 0
            :both-unconf [[20 1] "Temperature"]
            :own-unconf|other-conf [[22 0] "Temperature"]
            :other-site-unconf 3
            :other-site-conf 1}}
         :something-else]))
(->> @input
     first
     (mapv :site-id))