我今天一直在研究4Clojure的问题,我在问题28上遇到了麻烦,实现了扁平化.
我的代码存在一些明确的问题.
(fn [coll]
((fn flt [coll res]
(if (empty? coll)
res
(if (seq? (first coll))
(flt (into (first coll) (rest coll)) res)
(flt (rest coll) (cons (first coll) res))))) coll (empty coll)))
Run Code Online (Sandbox Code Playgroud)
我可以用一些关于如何思考几个问题的指针.
如何确保我不更改结果列表的顺序?cons并且conj两者都在添加元素的地方添加元素(在列表的开头,向量的末尾等),所以我看不出在使用泛型时我应该如何控制它序列.
如何处理不同类型的嵌套序列?例如,'(1 2 [3 4])输出将输出([3 4] 2 1),而输入[1 2 '(3 4)]将输出(4 3 2 1)
我是否从"正确"角度接近这个?我应该使用带累加器的递归内部函数来执行此操作,还是我错过了一些明显的东西?
我有以下选择:
<select name="mySelect">
<option value="1">hello [test]</option>
<option value="2">hello2 [test2]</option>
<option value="3">hello33 [test33]</option>
<option value="4">hel [hel]</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如何对齐选项内的文本以显示如下:
hello____[test]
hello2___[test2]
hello33__[test33]
hel_____ [hel]
Run Code Online (Sandbox Code Playgroud)
我尝试使用 JavaScript 添加空格,但它们不可见。( _ 是上面的空格字符)
Scala中有一个字符串列表.让我们假设这些字符串只包含英文字母(小写和大写).以下是示例清单:
val l1 = List("ab","aa", "bc","Aa", "Ab", "Ba", "BB")
Run Code Online (Sandbox Code Playgroud)
当我们用以下代码对它进行排序时:
l1.sortWith(_ < _)
Run Code Online (Sandbox Code Playgroud)
我们会收到:
List(Aa, Ab, BB, Ba, aa, ab, bc)
Run Code Online (Sandbox Code Playgroud)
所以这种排序使用字母之间的以下关系:
A < B < C < ... < a < b < c ...
Run Code Online (Sandbox Code Playgroud)
我们也可以使用:
l1.sortWith(_.toLowerCase < _.toLowerCase)
Run Code Online (Sandbox Code Playgroud)
接收:
List(aa, Aa, ab, Ab, Ba, BB, bc)
Run Code Online (Sandbox Code Playgroud)
所以现在字母之间的关系是:
(a=A) < (b=B) < (c=C) ...
Run Code Online (Sandbox Code Playgroud)
但是如何使用以下字母顺序在Scala中对它们进行排序?:
a < A < b < B < c < C ...
Run Code Online (Sandbox Code Playgroud)
所以结果应该是;
List(aa, ab, Aa, Ab, bc, Ba, BB)
Run Code Online (Sandbox Code Playgroud) 我发现scala'-i'命令行选项对于运行一些scala代码然后将我转储到交互式shell中非常有用,因此我可以生成/检查它定义的内容.
有一件事让我完全神秘:为什么它加载并运行脚本两次?
例如,给定文件test.scala包含cannonical
println("Hello world")
Run Code Online (Sandbox Code Playgroud)
赛跑
scala -i test.scala
Run Code Online (Sandbox Code Playgroud)
生产:
$ scala -i test.scala
Loading test.scala...
Hello world
Loading test.scala...
Hello world
Welcome to Scala version 2.7.5final (Java HotSpot(TM) Client VM, Java 1.6.0_12).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
Run Code Online (Sandbox Code Playgroud)
显然运行两次并不是太令人头痛,但是对于运行需要一段时间的脚本来说很烦人(我正在使用[Project Euler]((https://projecteuler.net)问题来学习scala)
我假设我在某种程度上误解了-i选项的意图或用法......如何让我的脚本文件只运行一次?
(FWIW,我和Debian/Lenny一起使用Squeeze的scala包.)
[我不想要Unicode字符]
例如:使用黑色向下三角形.
它-webkit-appearance: none;会使它看起来更好.
它很简单:
Select ?
to to
Select ?
Value1
Value2
或类似的东西
HTML:
<select>
<option>Value1</option>
<option>Value2</option>
</select>
Run Code Online (Sandbox Code Playgroud)
问题:如何在纯CSS中完成,没有任何JavaScript?
这是我到目前为止:
//project Eular Problem 4: Prime Factors
#include<iostream>
#include<cmath>
typedef unsigned long long int uint_64;
using namespace std;
void storeFactors(uint_64 factors[], uint_64 num)
{
for(uint_64 i=0;i*i<num;i++
factors[i]=1; //assign 1 to all the values
for(uint_64 j=2; j*j<num;j++){
if(num%j!=0)
factors[j]=0; //assign 0 to non-factors
}
}
//Sieve of Eratosthenes to generate primes
void gen_primes(uint_64 arr[],uint_64 firstElement, uint_64 lastElement, uint_64 size)
{
for(uint_64 i=0;i<size;i++) //assigning 1 to all the values
arr[i]=1;
for(uint_64 i=2;i*i<=lastElement;i++){ //loop until the square-root of n
if(arr[i])
for(uint_64 j=i;j*i<=lastElement;j++) //eliminate …Run Code Online (Sandbox Code Playgroud) 我正在尝试解决这个问题,但它始终无法通过测试.
这是我的解决方案:
(= (- 10 (* 2 3)) 4)
Run Code Online (Sandbox Code Playgroud)
我在Chrome和Firefox上试过这个,结果相同.
我得到一个 HTMLselect选项,它是用 PHP 生成的。选项的名称是目录中的文件夹。现在我需要 jQuery 脚本中的值。我只知道命令$('#select :selected').text()或$(#select).val()两者都只是给我带来当前选择的选项。
PHP 的选择框:
<select id="existAlbum" name="existAlbum" size="1">
<option>SELECT ALBUM</option>
<?PHP
foreach ($alledateien as $datei) {
$dateiinfo = pathinfo($album."/".$datei);
if ($datei != "." && $datei != ".." && $datei != "background.jpg" && $datei != "loading.gif") {
echo ('<option>' . $datei . '</option>');
};
};
?>
</select>
Run Code Online (Sandbox Code Playgroud)
是否可以添加 jQuery 数组中的所有值?
我需要将选项值与其他单词进行比较。
如果我使用带有select()调用的非阻塞套接字而不是使用带有select()调用的阻塞套接字,我的程序将如何在行为上有所不同?
我有一个简单的库存数据库,在input_data表单中,其中一个输入字段是字段,如下所示:
<select>
<option>In Inventory</option>
<option>In Process</option>
<option>Shipped/in-transit</option>
<option>Received by recipient</option>
</select>
Run Code Online (Sandbox Code Playgroud)
例如,如果我使用"正在处理"输入数据,之后我想更新该数据.我的update_page.php文件中的默认值返回"In Inventory".我想看到选中的"In Process"值.
以下是来自我的update_page.php的非工作代码的片段:
<select name="status" value="<?php echo $row['status']; ?>">
<option>In Inventory</option>
<option>In Process</option>
<option>Shipped/in-transit</option>
<option>Received by recipient</option>
</select>
Run Code Online (Sandbox Code Playgroud) html ×4
html-select ×4
clojure ×2
css ×2
scala ×2
c ×1
c++ ×1
command-line ×1
debian ×1
interactive ×1
javascript ×1
jquery ×1
menu ×1
mysql ×1
nonblocking ×1
php ×1
shell ×1
sorting ×1