需要帮助使用函数转换地图中的数据
(defn transform-map-1 [past-step dir]
(cond (= dir "v")
(list (first (first past-step))
(+ -1 (first (first past-step))))
(= dir "^")
(list (first (first past-step))
(+ 1 (first (first past-step))))
(= dir ">")
(list (+ 1 (first (first past-step)))
(first (first past-step)))
(= dir "<")
(list (+ -1 (first (first past-step)))
(first (first past-step)))))
此函数采用 x,y 格式的两个输入坐标作为过去的步骤和方向上下左右以提供更新坐标
我想要做的是提供一系列的方向,并为每个方向返回更新的坐标
输入字符串 "^>v<" ,输出应为 ((0,1) (1,1) (1,0) (0,0)
我们从坐标 (0.0) 开始,第一个变换的输出成为第二个字符的输入
我能得到的最好的结果是但它给了我一个错误
(map (transform-map-1 ['(0, 0)] %1)(char-array string-test))