小编Fra*_*man的帖子

如何在d3v4力模拟中设定重力强度

我在这里读过api,说x.strength和y.strength将设置引力的强度:https: //github.com/d3/d3-force/blob/master/README.md#x_strength

但我该如何申请呢?

simulation = d3.forceSimulation()
    .force("link", d3.forceLink().id(function (d) {
        return d.id;
    }).distance(10))
    .force("charge", d3.forceManyBody().strength(-15))
    .force("center", d3.forceCenter(width * 0.5, height / 2))
Run Code Online (Sandbox Code Playgroud)

d3.js

1
推荐指数
1
解决办法
4737
查看次数

clojure 中的条件来构建字符串并更新变量

我想尝试一下 clojure,做一个拼图,打印从开始到目标的路径。我的尝试是不打印任何内容。

我知道我已经以程序方式编写了此内容,但不确定考虑以功能方式编写此内容的最佳方法。所以我想了解为什么这不打印任何内容,如何让条件执行 2 个操作(即:将方向添加到字符串并更新位置。我在网上找到的所有示例仅执行 1 个操作),以及如何真正使这项工作发挥作用。理想情况下,如何使我的方法发挥作用,以及理想的 clojure 方法是什么。

(defn -main [& args]
  (def x 2)
  (def y 3)
  (def t_x 10)
  (def t_y 15)
  (while true
    (let [m ""]
      (cond
        (> y t_y) (let [m (str m "N")])(- y 1)
        (< y t_y) (let [m (str m "S")])(+ y 1)
        (> x t_x) (let [m (str m "W")])(- x 1)
        (< x t_x) (let [m (str m "E")])(+ x 1))

      ; A single line providing the move to be …
Run Code Online (Sandbox Code Playgroud)

loops clojure multiple-conditions

1
推荐指数
1
解决办法
394
查看次数

标签 统计

clojure ×1

d3.js ×1

loops ×1

multiple-conditions ×1