小编eug*_*100的帖子

在 Clojure 中调试线程宏 -> 或 ->>

我想了解为该问题设计的以下代码是如何工作的:“给定一个整数序列,找到一个使其元素总和最大化的连续子序列”

defn max-subseq-sum [coll]
(->> (take-while seq (iterate rest coll)) ; tails (1)
   (mapcat #(reductions conj [] %)) ; inits   (2)
   (apply max-key #(reduce + %)))) ; max sum
Run Code Online (Sandbox Code Playgroud)

所以我想看看表格 (1)、(2) 和其他表格的输出。我可以在 Cursive 中设置断点,但我不知道如何获得这些值。我试图定义一个语言环境变量,例如

(defn max-subseq-sum [coll]
 (->> (take-while seq (iterate rest coll)) ; tails
      (let [d #(reductions conj [] %)]
       d  ) ; inits
      (apply  max-key #(reduce + %)))
 )

(max-subseq-sum [-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1])
Run Code Online (Sandbox Code Playgroud)

但我仍然不明白如何看到 d,例如

如何解决这个问题呢?

debugging clojure

4
推荐指数
2
解决办法
594
查看次数

在visual studio 2012中无法从异常返回代码

所有以前版本的Visual Studio都有非常有用的功能:如果我在try ... catch构造的catch块中创建一个断点,那么当发生异常时我可以拖动代码的当前位置来尝试阻塞.它允许我看到发生了什么错误.例如:

try
{
    int i=0;
    int j=1/i;
}
catch(Exception ex)
{
    string s="";  //here I may set a break point and then drag a cursor to try block
}
Run Code Online (Sandbox Code Playgroud)

但是在VS 2012中它是不可能的!我不能回来尝试阻止.可能是我错过了一些选项吗?如果他们取消了此功能,那将非常难过. 解决方案:我的网站位于应用程序池ASP.NET V4.0 Integrated下,其中属性"Enable 32-bit applications"设置为false.当我将应用程序池更改为其他应用程序并将此属性设置为True时,我成功返回到try块

c# exception visual-studio-2012

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

网站中静态变量的奇怪行为

我准备了一个非常简单的网站来演示此行为。

它具有一页和一个按钮以及以下代码的页面:

public partial class TestStatic : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    if (!IsPostBack)
    {
        Class1.SetValue();
        Label1.Text = Class1.st.ToString();
    }
  }
  protected void Button1_Click(object sender, EventArgs e)
  {
    Label1.Text = Class1.st.ToString();
  }
}
Run Code Online (Sandbox Code Playgroud)

一类:

public class Class1
{
  public Class1()
  {
  }
  public static int st = 0;
  public static void SetValue()
  {
    st = 1;
  }
}
Run Code Online (Sandbox Code Playgroud)

因此,在加载页面时,您会在Label1中看到st = 1。如果用户单击Buttton,有时您会看到st = 0,有时st = 1。在调试中,我看到有时命令

public static int st = 0;
Run Code Online (Sandbox Code Playgroud)

当用户单击Button时执行,这就是将st更改为零的原因。我只能在框架4.5中重现此行为:在框架3.5中不会发生。有人可以解释我这种行为吗?

c# asp.net variables static .net-4.5

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

在clojure函数中使用过滤器

为什么

(filter even? (range 10))
Run Code Online (Sandbox Code Playgroud)

给出(0 2 4 6 8)

((fn [x] filter even? x)
          (range 10))
Run Code Online (Sandbox Code Playgroud)

(0 1 2 3 4 5 6 7 8 9)
Run Code Online (Sandbox Code Playgroud)

function clojure

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