小编gge*_*ond的帖子

从Python迁移到Racket(正则表达式库和"Racket Way")

我正在尝试学习Racket,并在此过程中尝试重写Python过滤器.我的代码中有以下一对函数:

def dlv(text):
    """
    Returns True if the given text corresponds to the output of DLV
    and False otherwise.
    """
    return text.startswith("DLV") or \
           text.startswith("{") or \
           text.startswith("Best model")

def answer_sets(text):
    """
    Returns a list comprised of all of the answer sets in the given text.
    """
    if dlv(text):
        # In the case where we are processing the output of DLV, each
        # answer set is a comma-delimited sequence of literals enclosed
        # in {}
        regex = re.compile(r'\{(.*?)\}', re.MULTILINE)
    else: …
Run Code Online (Sandbox Code Playgroud)

python regex porting racket

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

如何定义在 ZSH 提示中使用的自定义颜色?

我在配置 zsh 提示时遇到了一些困难。具体来说,我希望字体具有由十六进制代码定义的颜色:#87afdf

目前,我已按如下方式设置提示:

PROMPT='%B[%d] 
?  %b'
Run Code Online (Sandbox Code Playgroud)

我尝试通过以下方式添加颜色:

autoload -U colors && colors

PROMPT='%{$fg[#87afdf]%}%B[%d]
?  %b%{$reset_color%}'
Run Code Online (Sandbox Code Playgroud)

但这只会给我以下胡言乱语:

$fg[#87afdf][/Users/gregory]
?  $reset_color
Run Code Online (Sandbox Code Playgroud)

任何关于如何进行的想法将不胜感激。

configuration zsh prompt zshrc

6
推荐指数
3
解决办法
8500
查看次数

使用Racket scribble/lp进行文学编程的例子

除了学习Racket,我还在努力学习文学编程.不幸的是,关于scribble/lp,Racket文档很少说.有人能指出我在这个主题上有更好的资源或用Racket编写的文学程序的例子吗?

非常感谢你.

literate-programming racket scribble

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