问题列表 - 第42200页

你能帮我重构这段clojure代码来生成seq吗?

我想生成一个seq,我以后可以做(映射).它应该如下所示:

((0 0) (0 1) (0 2) (0 3) ... (7 7))
Run Code Online (Sandbox Code Playgroud)

我现在必须要做的这段代码看起来非常非常难以产生如此简单的结果.我需要一些帮助才能做到这一点.

(loop [y 0 x 0 args (list)]  
  (if (and (= y 7) (= x 7))  
    (reverse (conj args (list y x)))  
    (if (= x 7)  
    (recur (+ y 1) 0 (conj args (list y x)))  
    (recur y (+ x 1) (conj args (list y x))))))  
Run Code Online (Sandbox Code Playgroud)

refactoring clojure

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

在scala中使用部分应用函数有哪些应用/优点?

我们在Scala中部分应用了函数 -

def sum(a:Int,b:Int,c:Int) = a+b+c

val partial1 = sum(1,_:Int,8)
Run Code Online (Sandbox Code Playgroud)

我想知道使用部分应用函数有什么好处.或者它只是一个语法上的添加?

scala partial-application

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

jQuery的函数($)(jQuery)语法

可能重复:
jQuery:什么(function($){})(jQuery); 意思?

我偶然发现了下面的代码(包含在一个文件中),但我无法理解它的真正含义.

(function ($) {
    function doSomething1(somedata) {

    }

    function doSomething1(somedata) {

    }
})(jQuery);
Run Code Online (Sandbox Code Playgroud)

问题1:这种语法在jQuery的上下文中意味着什么

问题2:如何从其他文件(如HTML索引文件和其他JavaScript文件)中调用这些函数?

谢谢

javascript api jquery

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

为什么在nasm中使用外部c函数会破坏这段代码?

我在使用外部c函数调试我的nasm程序时遇到了问题.

%macro pint 1
  pushad
  push %1
  call printint
  popad
%endmacro

section .text
      extern printint
      global main
   main:
      mov eax, 3
      pint eax
      dec eax
      pint eax

      mov eax,1
      mov ebx,0
      int 0x80
Run Code Online (Sandbox Code Playgroud)

而printint的定义如下:

 void printint(int a) { 
   printf("%d\n",a);
 }
Run Code Online (Sandbox Code Playgroud)

我得到的输出是第一次打印(如预期)的3和第二次打印的随机数.有人告诉我的printf()可能会改变CPU寄存器的值没有恢复它们,所以我想保存在堆栈中所有寄存器调用的printf将防止任何寄存器更改前,但显然事实并非如此.
任何人都可以解释为什么奇怪的输出,我该如何解决它?

谢谢.

c assembly external nasm

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

String ... java中的键

可能重复:
Java,参数中有3个点

jedis中正在使用构造String... keys(这是新的东西?)

例如这种方法

jedis.blpop(int timeout, String... keys);
Run Code Online (Sandbox Code Playgroud)

我相信你可以将它用作String作为数组.我如何在我的代码中使用它(示例)?

java

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

Python 2.x与Python 3.x中的BufferedReader

我有一个在Python 2和Python 3中运行的程序,但速度有很大差异.我理解在交换机中进行了一些内部更改,但io.BufferedReader的差异非常大.在这两个版本中,我都使用io.BufferedReader,因为主程序循环一次只需要一个字节的数据.以下是脚本的cProfile输出的摘录(请参阅cumtime,而不是tottime):

Python 2:
 ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 36984   0.188    0.000    0.545    0.000   io.py:929(read)

Python 3:
 36996    0.063   0.000    0.063    0.000   {method 'read' of '_io.BufferedReader' objects}
Run Code Online (Sandbox Code Playgroud)

当我打印对象时,两者都返回类似的东西io.BufferedReader,我确信它们都使用BufferedReader.

是有问题的代码.见第28行.调用者负责设置bufstream.我用了bufstream = io.open('testfile', 'rb')

为什么BufferedReader的速度在读取文件中的单个字节方面存在如此巨大的差异,以及如何"修复"Python 2.x的问题?我正在运行Python 2.6和Python 3.1.

python performance bufferedreader python-3.x

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

为什么这个python脚本会一直等到执行计时器线程?

from threading import Timer

def startTimer():

  t = Timer(10.0, foo, ['hello world', 'tell me more'] )
  t.start()
  print 'Timer function invoked'
  print 'function exit'

def foo(msg, msg2):
  print 'foo was executed'
  print msg
  print msg2

if __name__ == '__main__':  
  startTimer()
  print 'end of program'
Run Code Online (Sandbox Code Playgroud)

我已将上述代码保存在文件(timer.py)中,然后在shell中键入python timer.py.但它一直等到foo()被执行.为什么会这样?你怎么称呼这种行为/执行方式?

python execution

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

PHP,Swift-mailer问题

当我点击我的联系页面上的提交按钮,尝试提交使用swift-mailer的表单时,我得到了:

警告:fopen(uploads /)[function.fopen]:无法打开流:/home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php中没有这样的文件或目录131

Fatal error: Uncaught exception 'Swift_IoException' with message 'Unable to open file for reading [uploads/]' in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php:133

Stack trace: 
#0 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php(77): Swift_ByteStream_FileByteStream->_getReadHandle()
#1 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(660): Swift_ByteStream_FileByteStream->read(8192) 
#2 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(337): Swift_Mime_SimpleMimeEntity->_readStream(Object(Swift_ByteStream_FileByteStream)) 
#3 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(448): Swift_Mime_SimpleMimeEntity->getBody()
#4 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(463): Swift_Mime_SimpleMimeEntity->toString()
#5 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php on line 133
Run Code Online (Sandbox Code Playgroud)

服务器上存在完整路径,但错误消息显示"没有此类文件或目录".可能是什么问题呢?谢谢大家!祝圣诞快乐!

php swiftmailer

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

同一HTML页面上的不同颜色链接

嗨,我想在同一页面上有不同的颜色链接.我想要一些链接为蓝色,一些链接为黑色.我是html和CSS的新手,所以提前谢谢你!

-Spencer

html css colors hyperlink

10
推荐指数
2
解决办法
7万
查看次数

如何在Android中列出所有媒体?

我正在为Android构建一个专门的媒体播放器,需要一种从设备中选择一首歌的方法.我喜欢内置音乐播放器如何按艺术家/专辑分组,这是我必须写的东西,还是有什么我可以插入来免费获得该功能?

通过idtag信息进行一些基本分组,在手机上列出音乐文件的最简单方法是什么?

android

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