小编And*_*een的帖子

如何在F#类型提供程序中构建一个仲裁curry函数?

在尝试让类型提供程序生成更多惯用代码时,我开始考虑从提供程序返回curried函数.

这段代码片段:

let lambdaTest () =
    let inner =
        <@ fun myInt ->
                fun int2 -> sprintf "A string! %d %d" myInt int2 @>
    let innerType = inner.GetType()
    ProvidedProperty(
        "lambda", 
        innerType.GenericTypeArguments.[0], 
        IsStatic = true, 
        GetterCode = fun _ -> inner.Raw)
Run Code Online (Sandbox Code Playgroud)

int -> int -> string如果我事先知道所需的签名,似乎可以提供; 但理想情况下我想动态构建嵌套的lambda函数,如下所示:

let rec inline curry<'a> format (func: Quotations.Expr<'a>) : Quotations.Expr<'a> =
    match format with
    | FString f ->
        curry<string -> 'a> f <@ fun (s : str) -> %func @>
    | FInt f -> …
Run Code Online (Sandbox Code Playgroud)

f# currying type-providers

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

在 Dart 编程语言中调用嵌套函数

我在这里定义了一个内部函数:

person(firstName, lastName){
    fullName(){ //Is it possible to invoke this function outside the 'person' function?
        return firstName + " "  + lastName;
    }
    firstInitial(){
        return firstName[0];
    }
    lastInitial(){
        return lastName[0];
    }
}
Run Code Online (Sandbox Code Playgroud)

接下来,我尝试从“main”函数调用“fullName”函数:

void main() {
  print(person("Rob", "Rock").fullName());
}
Run Code Online (Sandbox Code Playgroud)

但它产生了这个错误:

Uncaught TypeError: Cannot read property 'fullName$0' of undefined
Run Code Online (Sandbox Code Playgroud)

是否可以在定义函数的范围之外调用内部函数?

dart

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

检查REBOL字符串是否包含另一个字符串

我尝试使用find功能来检查字符串出现的"ll"字符串中"hello",但它返回"ll"的替代truefalse:

"This prints 'll'"
print find "hello" "ll"
Run Code Online (Sandbox Code Playgroud)

REBOL的标准库是否有任何函数来检查字符串是否包含另一个字符串?

rebol

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

获取与正则表达式匹配的字符串中的所有子字符串

可能重复:
如何在JavaScript中使用类似于PHP的preg_match_all()的正则表达式匹配多次出现?

在Javascript中,是否可以在字符串中找到与正则表达式匹配的所有子字符串的起始和结束索引?

功能签名:

function getMatches(theString, theRegex){
    //return the starting and ending indices of match of theRegex inside theString
    //a 2D array should be returned
}
Run Code Online (Sandbox Code Playgroud)

例如:

getMatches("cats and rats", /(c|r)ats/);
Run Code Online (Sandbox Code Playgroud)

应该返回数组[[0, 3], [9, 12]],该数组表示字符串中"cats"和"rats"的起始和结束索引.

javascript regex

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

在Javascript中识别重复的函数

是否有可能在Javascript中检测重复的功能(在某些情况下可能会意外写入)?在Google Chrome中,

printLah(); //this prints "Haha" for some reason, without even printing an error message in the Javascript console!
function printLah(){
    alert("Hahah!");
}


function printLah(){
    alert("Haha");
}
Run Code Online (Sandbox Code Playgroud)

这是JSfiddle.

javascript

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

Dart编程语言是否具有与Javascript的“原型”等效的功能?

在Dart中,函数是否可以具有与之关联的原型?

示例JavaScript代码:

doStuff.prototype.isDefined = true; //is there anything like Javascript's function prototypes in Dart?
function doStuff(){
    console.log("The function doStuff was called!");
}
Run Code Online (Sandbox Code Playgroud)

是否有可能在Dart中做到这一点(即为每个函数创建属性列表?)

dart

3
推荐指数
2
解决办法
1131
查看次数

是否有可能检测到Haxe中的当前操作系统?

在Haxe,有没有办法获得当前操作系统的名称?我正在寻找一种适用于所有Haxe目标语言的方法.

haxe

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

使用 shell 脚本启动“选择文件”对话框

在 Ubuntu 中,是否可以从命令行启动“选择文件”对话框?我需要找到一个启动“选择文件”对话框的命令(以便我可以提示用户使用 shell 脚本导航到一个文件,然后返回文件路径。)

bash ubuntu

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

在外部单击时自动关闭JFrame窗口

我在这里有一个相当基本的JFrame,当用户点击它时,我想让窗口自动关闭.当用户点击窗口时(通过某种方式检测窗口外的点击?),是否可以关闭窗口?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ExampleJFrame {

    public static void main(String[] args) {
        JFrame frame = new JFrame("How can I make this window close when I click outside it?");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        JLabel jlbempty = new JLabel("");
        jlbempty.setPreferredSize(new Dimension(200, 200));
        frame.getContentPane().add(jlbempty, BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

java swing jframe

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

Haxe中的阵列有多种类型

在Javascript中,可以在一行代码中创建一个包含嵌套数组的数组.是否可以在Haxe中做相同的操作?

var a = [
    ["This is a nested array"],
    ["This is another nested array"],
    "This is not a nested array"
];
Run Code Online (Sandbox Code Playgroud)

haxe

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

标签 统计

dart ×2

haxe ×2

javascript ×2

bash ×1

currying ×1

f# ×1

java ×1

jframe ×1

rebol ×1

regex ×1

swing ×1

type-providers ×1

ubuntu ×1