我想搜索一个Chars列表的列表, [[Char]]确定Char是否在列表中,返回true或false.到目前为止我有这个,
scanBoard :: [[Char]] -> Bool
scanBoard board
| 'r' `elem` board = True
| 'i' `elem` board = True
| otherwise = False
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在搜索"o"然后用"o"打印所有行.我必须申请的任何建议/代码?
data.txt中:
j,o,b:
a,b,d:
o,l,e:
f,a,r:
e,x,o:
Run Code Online (Sandbox Code Playgroud)
期望的输出:
j,o,b:
o,l,e:
e,x,o:
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在我的应用中实施搜索。我遵循了Google的教程,但是现在,当我按下“搜索”按钮(位于设备/仿真器上)时,什么也没出现。我不知道为什么。
我的searchable.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<searchable
xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/label_search"
android:hint="@string/search_hint"
android:includeInGlobalSearch="true"
>
</searchable>
Run Code Online (Sandbox Code Playgroud)
这是Search-Activity的Android清单部分:
<!-- Search Activity -->
<activity android:name=".SearchNotes">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
Run Code Online (Sandbox Code Playgroud)
填充我的ListActivity的代码:
private void searchAndDisplay(String query){
SQLiteDatabase db = db_con.getReadableDatabase();
final Cursor c = db.rawQuery(
"SELECT headline, id as '_id' FROM entry WHERE " +
"(headline LIKE '%?%') OR (content LIKE '%?%') ",
new String[]{query, query});
this.startManagingCursor(c);
final ListAdapter searchAdapter = new SimpleCursorAdapter(
this,
android.R.layout.simple_list_item_2, c,
new …Run Code Online (Sandbox Code Playgroud) 我想要做的是创建一个方法,它有一个字符串和一个字符作为参数,然后该方法接受字符串并搜索给定的字符.如果字符串包含该字符,则返回字符所在的整数数组.这是我到目前为止:
public class Sheet {
public static void main(String[] args) {
String string = "bbnnbb";
String complete = null;
//*******
for(int i = 0; i < string.length(); i++){
complete = StringSearch(string,'n').toString();
}
//********
}
public static int[] StringSearch(String string, char lookfor) {
int[]num = new int[string.length()];
for(int i = 0; i < num.length; i++){
if(string.charAt(i)== lookfor){
num[i] = i;
}
}
return num;
}
Run Code Online (Sandbox Code Playgroud)
}
该方法工作正常,并返回此:
0
0
2
3
0
0
Run Code Online (Sandbox Code Playgroud)
我想做的是将它们变成1个字符串,所以它看起来像这个"002300".有没有办法做到这一点?我试图在代码的星号区域中做到这一点,但我没有成功.
我有一个struct包含一些int和bool成员的,我希望从列表中获得最低值(实际上是基于A*搜索的路径查找器).
基本上,我的对象看起来像这样:
public struct Tile
{
public int id;
public int x;
public int y;
public int cost;
public bool walkable;
public int distanceLeft;
public int parentid;
}
Run Code Online (Sandbox Code Playgroud)
我想得到距离最低的物品.列表声明如下:
List<Structs.Tile> openList = new List<Structs.Tile>();
Run Code Online (Sandbox Code Playgroud)
并以这种方式分配值:
while (pathFound == null)
{
foreach (Structs.Tile tile in map)
{
foreach (Structs.Tile tile1 in getSurroundingTiles(Current))
{
if (tile1.x == tile.x && tile1.y == tile.y)
{
Structs.Tile curTile = tile1;
curTile.parentid = Current.id;
curTile.distanceLeft = (Math.Abs(tile.x - goalx) + …Run Code Online (Sandbox Code Playgroud) 如何在Haskell中搜索二叉搜索树中的元素?我定义了我的树:
data Tree a =
Null |
L a |
N (Tree a) a (Tree a)
deriving Show
Run Code Online (Sandbox Code Playgroud)
我想创建一个在BST中搜索元素的函数:
findElem :: Tree a -> a -> Maybe a
findElem tree n = ...
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我的桌子被称为"asd"
我有这个架构:
id | date | content |
AUTO_INC DATETIME LONGTEXT
Run Code Online (Sandbox Code Playgroud)
现在假设 content = 45,67,89,3,45,5
我search COUNT()在这张桌子上怎么样WHERE content CONTAINS 89?
我尝试SELECT COUNT() FROM asd WHERE content IN(89);但没有结果.
我是python的新手所以请原谅我的无知.
我希望创建一种搜索一个文本文件的方法,以获得符合搜索条件的文件列表.然后使用结果在through/recurse目录中搜索这些文件,并将它们全部复制到一个主文件夹中.
基本上我有一个文件名大量的文本文件,我已设法搜索文件并检索所有以'.mov'结尾的文件,并将结果打印/输出到文本文件.可能有几十个文件.
然后,我如何使用这些结果递归搜索目录并将文件复制到新位置.
或者,我是以完全错误的方式解决这个问题的?
非常感谢!
删除字符串的所有字符的最佳方法,直到符合新行字符python?
str = 'fakeline\nfirstline\nsecondline\nthirdline'
into
str = 'firstline\nsecondline\nthirdline'
Run Code Online (Sandbox Code Playgroud) 我正在搜索超过10000行的数据集.我已经提到了可用的dom结构.虽然我尝试在单次输入后进行实时搜索检查每个结果,但我的浏览器正在挂起.有没有其他有效的方法可以降低其复杂性.
<label class="label">
<input type="checkbox" name="123" value="">
</label>
<label class="label">
<input type="checkbox" name="123" value=" General AUX"> General AUX
</label>
<label class="label">
<input type="checkbox" name="123" value=" Annser"> Annser
</label>
<label class="label">
<input type="checkbox" name="123" value=" LRIPL"> LRIPL
</label>
<label class="label">
<input type="checkbox" name="123" value=" Soy Impulse"> Soy Impulse
</label>
Run Code Online (Sandbox Code Playgroud)
**是的,实时搜索DOM**JS代码,我用于实时搜索
$(".form-container #filter").keyup(function() {
var filter = $(this).val(),
count = 0;
if(filter.length>=2){
// Loop through the comment list
$(".label").each(function() {
// If the list item does not contain the text phrase fade …Run Code Online (Sandbox Code Playgroud)