RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-245420

limitedeternity's questions

Martin Hope
limitedeternity
Asked: 2020-03-22 06:32:19 +0000 UTC

Haskell:是否可以将长度为 n 的列表的元素应用于函数?

  • 2

有这样一种情况:

  • 有一个功能fn :: Bool -> Bool -> Bool -> Bool。

  • 有一个由函数参数的可能值列表组成的列表fn:([[False, False, False], ... , [True, True, True]]由函数参数的数量生成)

我想在Python中实现类似“星号表达式”的东西:fn(*[a,b,...,z]) == fn(a,b,...,z) 并做这样的事情来获取所有“参数”列表的函数值:map (t $ fn) [[False, False, False], [True, True, True]]where t f [x,y,z] = f x y z.

问题是参数fn可能不是三个,而是或多或少。As 分别是 和 "argument" 列表中的元素。

如何实现一个函数t,以便它将具有可变数量元素的列表作为第二个参数?提前致谢!

编辑:

我达到了理想的解决方案,似乎:foldl a (\x -> \y -> \z -> z) [1,2,3]在哪里a = \f -> \x -> f x。让我们做一个 beta 减少:

  1. a (\x -> \y -> \z -> z) 1== (\x -> (\t -> \y -> \z -> z) x) 1==\y -> \z -> z
  2. a (\y -> \z -> z) 2== (\x -> (\y -> \z -> z) x) 2==\z -> z
  3. a (\z -> z) 3== (\x -> (\z -> z) x) 3==3

但:

    • Occurs check: cannot construct the infinite type: t0 ~ t0 -> t0
      Expected type: (t0 -> t0 -> t0 -> t0) -> t0 -> t0 -> t0 -> t0 -> t0
        Actual type: (t0 -> t0 -> t0 -> t0 -> t0)
                     -> t0 -> t0 -> t0 -> t0 -> t0
    • In the first argument of ‘foldl’, namely ‘a’
      In the second argument of ‘($)’, namely
        ‘foldl a (\ x -> \ y -> \ z -> z) [1, 2, 3]’
      In the second argument of ‘($)’, namely
        ‘show $ foldl a (\ x -> \ y -> \ z -> z) [1, 2, 3]’

查德特?

функции
  • 1 个回答
  • 10 Views
Martin Hope
limitedeternity
Asked: 2020-05-12 02:20:50 +0000 UTC

如何将数据从文件转换为字典?

  • 1

我有一个包含以下内容的文本文件:

position=5
quantity=2
position_final=10
quantity_final=2

如何呈现这些数据{'position': 5, 'quantity': 2, 'position_final': 10, 'quantity_final': 2}?提前致谢。

python
  • 2 个回答
  • 10 Views
Martin Hope
limitedeternity
Asked: 2020-05-08 19:57:47 +0000 UTC

从 Django 页面运行 Python 脚本

  • 0

list.html中有一个特定的按钮:

{% load static %}
...
{% include "execute.html" %}
...
<button type="button" id="id">Execute Script</button>

意见.py:

import subprocess
import os
...
def exec_com(request):
if request.is_ajax():
    if request.method == 'POST':
        command = request.POST['cmd']
        os.chdir('../static/tools/')
        return subprocess.call(command, shell=True)
    return HttpResponseRedirect(reverse('list'))

网址.py:

url(r'^execute/$', views.exec_com, name='execute'),

执行.html:

{% load static %}
<script src="{% static 'js/jquery.cookie.min.js' %}"></script>
<script type="text/javascript">
$(document).on('ready', function(){
   $('#id').on('click', function(){
        data = {
            "cmd": "id.py"
        }
        $.ajax({
             headers: { "X-CSRFToken": $.cookie("csrftoken") },
             url : window.location.href,
             type: "POST",
             data: data,
             dataType: "text",
             async: "asynchronous",
             success: function(data) {
                  alert("Executed.")
                  console.log(data)
             },
             error: function(xhr,errmsg,err) {
                  alert("Something wrong.")
                  console.log(xhr.status + ": " + xhr.responseText)
             }
        });
    });
 });
 </script>

单击时,脚本不执行。你能告诉我我错过了什么或做错了什么吗?
提前致谢。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
limitedeternity
Asked: 2020-04-18 04:01:25 +0000 UTC

如何将列表拆分为包含相同连续元素的嵌套列表?

  • 1

如何将列表拆分为包含连续相同元素的嵌套列表?

如果没有连续的相等元素,您必须创建一个只包含这个元素的嵌套列表。

就像是:

它是:array = [4, 2, 2, 4, 5, 5, 5, 1, 6, 9, 9, 2]

它变成了:array = [[4] [2, 2] [4] [5, 5, 5] [1] [6] [9, 9] [2]]

这样的事情如何实施?

提前致谢。

python
  • 4 个回答
  • 10 Views
Martin Hope
limitedeternity
Asked: 2020-04-12 23:13:58 +0000 UTC

如何将列表中第 k 个重复元素系列与列表中的最后一个系列交换?

  • 4

让k = 2

假设有一个列表:

array = [2,2,4,5,5,7,1,6,9,9,2]

需要这样做,以便:

array = [2,2,4,9,9,7,1,6,5,5,2]
python
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5