扛刀软妹

文章 评论 浏览 32

扛刀软妹 2025-02-20 16:50:43

您正在定义两个不同的变量,称为用户名,其中第一个是在main()方法中定义的,而另一个位于while方法代码>循环。

访问变量时,DART将从您所处的范围中搜索它,然后将搜索扩展到外部范围,如果它找不到变量。但是使用的表达式在确定循环时应继续,无法访问循环中定义的范围。因此,它看到了第一个用户名 main()中定义的变量。

因此,问题在于,当您使用var时,您告诉DART,它应该定义一个新变量而不是使用现有变量。

因此,代替:

    print('Sorry that is not the correct user name. Please try Again');
    var userName = stdin.readLineSync()!;

您应该只执行以下操作以参考称为用户名的现有变量:

    print('Sorry that is not the correct user name. Please try Again');
    userName = stdin.readLineSync()!;

You are defining two different variables called userName where the first are defined inside the main() method while the other are inside the scope of the while() loop.

When accessing a variable, Dart will search for it from the scope where you are and then widen the search to outer scopes if it does not find the variable. But the expression used by while when determining of the loop should continue, cannot access the scope defined inside the loop. So it sees the first userName variable defined in main().

So the problem is that when you use var, you are telling Dart that it should define a new variable instead of using an existing one.

So instead of:

    print('Sorry that is not the correct user name. Please try Again');
    var userName = stdin.readLineSync()!;

You should just do the following to refer to the existing variable called userName:

    print('Sorry that is not the correct user name. Please try Again');
    userName = stdin.readLineSync()!;

Dart False首次运行正常,但是如果我再次运行代码并以真实的方式开始,即使我输入false

扛刀软妹 2025-02-20 11:06:25

编辑

package com.demo;

// -- 
// imports for output
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
// --
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Demo {

    @Getter
    @RequiredArgsConstructor
    public static class Keys {
        private final String key1;
        private final String key2;
    }

    public static void main(String[] args) throws JsonProcessingException {
        //List1
        List<String> list1 = Arrays.asList("A", "B", "C");
        //List2
        List<Keys> list2 = Arrays.asList(
                new Keys("obj1", "A"),
                new Keys("obj2", "B"),
                new Keys("obj3", "D"),
                new Keys("obj4", "F")
        );
        
        List<Keys> filteredList = 
                //create sequential stream over the elements of list2
                list2.stream()
                        //filter using lambda
                        .filter(
                                //x - element of type Keys 
                                x 
                                ->
                                //predicate returns true - if list1 contains key2 value of stream element 
                                list1.contains(x.key2)
                        )
                        //collect stream to list
                        .collect(
                                //default list collector
                                Collectors.toList()
                        );
        
        //output with pretty printer
        ObjectWriter objectWriter = new ObjectMapper().writerWithDefaultPrettyPrinter();
        System.out.println(objectWriter.writeValueAsString(filteredList));
    }
}

输出示例:

[ {
"key1" : "obj1",
"key2" : "A"
}, {
"key1" : "obj2",
"key2" : "B"
} ]

EDITED:

package com.demo;

// -- 
// imports for output
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
// --
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Demo {

    @Getter
    @RequiredArgsConstructor
    public static class Keys {
        private final String key1;
        private final String key2;
    }

    public static void main(String[] args) throws JsonProcessingException {
        //List1
        List<String> list1 = Arrays.asList("A", "B", "C");
        //List2
        List<Keys> list2 = Arrays.asList(
                new Keys("obj1", "A"),
                new Keys("obj2", "B"),
                new Keys("obj3", "D"),
                new Keys("obj4", "F")
        );
        
        List<Keys> filteredList = 
                //create sequential stream over the elements of list2
                list2.stream()
                        //filter using lambda
                        .filter(
                                //x - element of type Keys 
                                x 
                                ->
                                //predicate returns true - if list1 contains key2 value of stream element 
                                list1.contains(x.key2)
                        )
                        //collect stream to list
                        .collect(
                                //default list collector
                                Collectors.toList()
                        );
        
        //output with pretty printer
        ObjectWriter objectWriter = new ObjectMapper().writerWithDefaultPrettyPrinter();
        System.out.println(objectWriter.writeValueAsString(filteredList));
    }
}

output example:

[ {
"key1" : "obj1",
"key2" : "A"
}, {
"key1" : "obj2",
"key2" : "B"
} ]

如何为列表的匹配元素创建Java谓词?

扛刀软妹 2025-02-20 02:16:05

HDFS没有像Mac这样的默认/用户文件夹。

无论如何

HDFS doesn't have a default /Users folder like a Mac.

It will only have the directories that you've created with hdfs mkdir

Hadoop prefers you use /user/ (singular, lowercase), anyway

我对HDFS Hadoop文件有错误,IDK有什么问题

扛刀软妹 2025-02-19 14:20:18

一个懒惰的单个条目,懒惰列中的每个条目是5个项目的一行,看起来适合您想要的东西。

A single LazyColumn, where each entry in the lazy column is a row of 5 items looks like it would fit what you want.

JetPack同时组成多个懒惰的滚动

扛刀软妹 2025-02-19 11:31:42

您可以通过以下代码来实现这一点:

const filtered_people = people.filter(function(person){
    return id_filter.includes(person.id) && person.gender === 'm';
});

只要确保每个人的ID是整数而不是字符串,就如您的示例。否则,Incluber()函数将无法匹配。另外,您的数组存在内部语法问题。因此,最终代码看起来像这样:

const people = [
    {id: 1, name: "abc", gender: "m", age:15},
    {id: 2, name: "a", gender: "m", age: 25},
    {id: 3, name: "efg", gender: "f", age: 5},
    {id: 4, name: "hjk", gender: "f", age: 35},
    {id: 5, name: "ikly", gender: "m", age: 41},
    {id: 6, name: "ert", gender: "f", age: 30},
    {id: 7, name: "qwe", gender: "f", age: 31},
    {id: 8, name: "bdd", gender: "m", age: 78}
]
const id_filter = [1,4,5,8]
const filtered_people = people.filter((person) => id_filter.includes(person.id) && person.gender === 'm')
console.log(filtered_people)

我希望这对您有帮助。
祝你好运。

You can achieve that by the following code:

const filtered_people = people.filter(function(person){
    return id_filter.includes(person.id) && person.gender === 'm';
});

Just make sure the id for each person is an integer and not an string, as in your example. Otherwise, the includes() function won't match. Also, your people array has internal syntax problems. So, the final code would look like this:

const people = [
    {id: 1, name: "abc", gender: "m", age:15},
    {id: 2, name: "a", gender: "m", age: 25},
    {id: 3, name: "efg", gender: "f", age: 5},
    {id: 4, name: "hjk", gender: "f", age: 35},
    {id: 5, name: "ikly", gender: "m", age: 41},
    {id: 6, name: "ert", gender: "f", age: 30},
    {id: 7, name: "qwe", gender: "f", age: 31},
    {id: 8, name: "bdd", gender: "m", age: 78}
]
const id_filter = [1,4,5,8]
const filtered_people = people.filter((person) => id_filter.includes(person.id) && person.gender === 'm')
console.log(filtered_people)

I hope this helps you.
Good luck.

基于JavaScript中另一个数组的对象的过滤器数组

扛刀软妹 2025-02-19 08:57:21

基于上一个答案中的脚本,但是在测试它之后,该单元格被填充了文本。

我已经修改了if语句以仅允许该单元为空时的公式:

function Week1IFBlankFormulas() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange("D6").activate();
  if (spreadsheet.getCurrentCell().isBlank()) {
    spreadsheet.getCurrentCell().setFormula('=iferror(filter(Directors!$A$3:$A$55,Directors!D$4:D$56=$A5),)');
    spreadsheet.getActiveRange().autoFill(spreadsheet.getRange("D6"), SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
  } else {
    return;
  }
};

Based on the script in the previous answer but after testing it the cell was filled even with the text in it.

I have modified the if statement to only allow the formula to be in when the cell is empty:

function Week1IFBlankFormulas() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange("D6").activate();
  if (spreadsheet.getCurrentCell().isBlank()) {
    spreadsheet.getCurrentCell().setFormula('=iferror(filter(Directors!$A$3:$A$55,Directors!D$4:D$56=$A5),)');
    spreadsheet.getActiveRange().autoFill(spreadsheet.getRange("D6"), SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
  } else {
    return;
  }
};

Google Sheep AppScript-返回公式如果单元格,如果空白

扛刀软妹 2025-02-19 00:42:30

有趣的问题。在这种情况下,值2将是SYCL内核中指令中的字面意义 - 我认为这是尽可能高的效率!您有一个轻微的并发症,您将隐式铸件从intfloat。我的猜测是,您可能会在设备组装中以float文字 2.0 。您的SYCL设备不必在运行时或类似的东西中从内存或铸造中获取该2,它只是存在于说明中。

同样,如果您有:

constexpr int c = 2;
// the rest of your code
[=](id<1> i) { inA[i] = inA[i] + c; }
// etc

编译器几乎可以肯定足够聪明,可以将c的常数值传播到内核代码中。因此,同样,2.0字面的说明最终出现在说明中。

我用DPC ++编制了您的示例,并提取了LLVM IR,并找到了以下行:

  %5 = load float, float addrspace(4)* %arrayidx.ascast.i.i, align 4, !tbaa !17
  %add.i = fadd float %5, 2.000000e+00
  store float %add.i, float addrspace(4)* %arrayidx.ascast.i.i, align 4, !tbaa !17

这显示了float Load&amp;在同一地址存储/从同一地址存储,并在两者之间使用“添加2.0”指令。如果我修改以使用我所展示的变量c,则获得相同的LLVM IR。

结论:您已经达到了最大的效率,并且编译器很聪明!

Interesting question. In this case the value 2 will be a literal in the instruction in your SYCL kernel - this is as efficient as it gets, I think! There's the slight complication that you have an implicit cast from int to float. My guess is that you'll probably end up with a float literal 2.0 in your device assembly. Your SYCL device won't have to fetch that 2 from memory or cast at runtime or anything like that, it just lives in the instruction.

Equally, if you had:

constexpr int c = 2;
// the rest of your code
[=](id<1> i) { inA[i] = inA[i] + c; }
// etc

The compiler is almost certainly smart enough to propagate the constant value of c into the kernel code. So, again, the 2.0 literal ends up in the instruction.

I compiled your example with DPC++ and extracted the LLVM IR, and found the following lines:

  %5 = load float, float addrspace(4)* %arrayidx.ascast.i.i, align 4, !tbaa !17
  %add.i = fadd float %5, 2.000000e+00
  store float %add.i, float addrspace(4)* %arrayidx.ascast.i.i, align 4, !tbaa !17

This shows a float load & store to/from the same address, with an 'add 2.0' instruction in between. If I modify to use the variable c like I demonstrated, I get the same LLVM IR.

Conclusion: you've already achieved maximum efficiency, and compilers are smart!

如何优化SYCL内核

扛刀软妹 2025-02-18 23:43:49

很长一段时间后,解决了错误,可以注意到路由器类逻辑有点更改了

@Slf4j
@Service
@AllArgsConstructor
public class MyService {
   final CamelContext context;

   @PostConstruct
   public void consumerData() {
     var rCamel = CamelReactiveStreams.get(context);
     var numbers = rCamel.fromStream("numbers", Integer.class);
     Flux.from(numbers).subscribe(e -> log.info("{}", e));
   }
}

@Component
@NoArgsConstructor
public class MyRouter extends RouteBuilder {


// Injects the Subscriber
@Autowired MyService service;

@Override
public void configure() {

  //onException(ReactiveStreamsNoActiveSubscriptionsException.class)
  //      .continued(true);

  from("timer://reactiveApp?fixedRate=true&period=2s")
        .transform(method(Random.class, "nextInt(100)"))
        //.log("${body}");
        .to("direct:message");

  from("direct:message")
        //.log("${body}")
        .to("reactive-streams:numbers");
  }
}

After a long time, solved the error, as can be noticed the Router Class logic was changed a little

@Slf4j
@Service
@AllArgsConstructor
public class MyService {
   final CamelContext context;

   @PostConstruct
   public void consumerData() {
     var rCamel = CamelReactiveStreams.get(context);
     var numbers = rCamel.fromStream("numbers", Integer.class);
     Flux.from(numbers).subscribe(e -> log.info("{}", e));
   }
}

@Component
@NoArgsConstructor
public class MyRouter extends RouteBuilder {


// Injects the Subscriber
@Autowired MyService service;

@Override
public void configure() {

  //onException(ReactiveStreamsNoActiveSubscriptionsException.class)
  //      .continued(true);

  from("timer://reactiveApp?fixedRate=true&period=2s")
        .transform(method(Random.class, "nextInt(100)"))
        //.log("${body}");
        .to("direct:message");

  from("direct:message")
        //.log("${body}")
        .to("reactive-streams:numbers");
  }
}

Apache骆驼反应流抛出该流没有主动订阅

扛刀软妹 2025-02-18 21:12:08

这样的导入:

const ipfsClient = require('ipfs-http-client');

然后创建连接:

const ipfs = ipfsclient.create( https://ipfs.infura.io:5001 );

上传:

const uploadfile =等待ipfs.add({content:file});

Import it like this:

const ipfsClient = require('ipfs-http-client');

Then create the connection:

const ipfs = ipfsClient.create(https://ipfs.infura.io:5001);

To upload:

const uploadFile = await ipfs.add({ content: file });

找不到模块:可以解决&#x27; ipfs-http-client&#x27; in&#x27; d:\ pro \ src \ components&#x27;

扛刀软妹 2025-02-18 14:48:42

您需要导入要在材料组件中使用的主题。

例如,您可以

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

用于全局CSS。

也有一次问题。 - &gt; Angular 5材料2:datePickerStyle

更多关于预建立主题的信息更多信息 - &gt; https://v6.material.angular.angular.angular.io/指南/主题#used-a-pre-built-theme

You need to import the theme you want to use within your material components.

For example you can use

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

for your global css.

Had the the problem once, too. --> Angular 5 Material 2: Datepickerstyle

More infos about the Prebuild themes --> https://v6.material.angular.io/guide/theming#using-a-pre-built-theme

Angular 13材料datepicker无法正确应用样式

扛刀软妹 2025-02-18 07:55:43

来自 msdn

在标识符开始时使用两个顺序下划线字符(__),或一个单一的领导下划线,然后是大写字母,用于所有范围的C ++实现。您应该避免使用一个领先的下划线下划线,然后是一个带有文件范围的名称的小写字母,因为可能与当前或将来的保留标识符发生冲突。

这意味着您可以将单个下划线作为成员变量前缀,只要接下来是下案字母。

这显然是从C ++标准的第17.4.3.1.2节中获取的,但是我找不到完整标准在线的原始来源。

另请参见这个问题

From MSDN:

Use of two sequential underscore characters ( __ ) at the beginning of an identifier, or a single leading underscore followed by a capital letter, is reserved for C++ implementations in all scopes. You should avoid using one leading underscore followed by a lowercase letter for names with file scope because of possible conflicts with current or future reserved identifiers.

This means that you can use a single underscore as a member variable prefix, as long as it's followed by a lower-case letter.

This is apparently taken from section 17.4.3.1.2 of the C++ standard, but I can't find an original source for the full standard online.

See also this question.

在C&#x2b;&#x2B中使用下划线的规则是什么。标识符?

扛刀软妹 2025-02-17 16:54:27

使用Mongoose 6.4

我通过删除_id:false架构类型选项来解决此问题。

并从响应中删除_id,而不必用_。motit() s或 delete> delete 到处我在模式中添加了以下模式类型选项:

toObject: {
    virtuals: true,
    transform(doc, ret) { 
        delete ret._id
    },
},

现在真正的问题是,为什么在服务器端生成ID时,简单地添加选项_id:false会导致猫鼬错误没有猫鼬的帮助?

错误:MongooseError:文档在保存之前必须具有_id
.../node_modules/mongoose/lib/model.js:291:18

我部分回答了我自己的问题,但是为此,我真的不知道。

Using Mongoose 6.4

I solved this by removing the _id: false schema type option.

and to remove the _id from the responses without having to pollute the routes with _.omit()s or deletes everywhere, I added the following schema type options to the schema:

toObject: {
    virtuals: true,
    transform(doc, ret) { 
        delete ret._id
    },
},

Now the real question is, why does simply adding the option _id: false results in the Mongoose error when you're generating the id on the server-side without the help of Mongoose?

Error: MongooseError: document must have an _id before saving at
.../node_modules/mongoose/lib/model.js:291:18

I partially answered my own question, but for this one... I really don't know.

架构选项_id:false和文档在保存错误发生之前必须具有_id

扛刀软妹 2025-02-17 16:45:29

仅假设

select distinct 
case when inp = 1 then gid
       when inp = 2 then pid
       when inp = 3 then did
  end new_id,
  case when inp = 1 then gname
       when inp = 2 then pname
       when inp = 3 then name
  end as name
from final
order by 2

Only assumption

select distinct 
case when inp = 1 then gid
       when inp = 2 then pid
       when inp = 3 then did
  end new_id,
  case when inp = 1 then gname
       when inp = 2 then pname
       when inp = 3 then name
  end as name
from final
order by 2

DB Fiddle playground

PSQL查询基于条件创建多个选择查询以滤除值

扛刀软妹 2025-02-17 07:49:58

这可能需要您对测试报告的需求,直接从您的Testrigor帐户下载。

This may suffice your need for test reports download direct from your testrigor account.

enter image description here

我们在测试物自动化工具中是否具有导出测试用例功能?

扛刀软妹 2025-02-17 05:16:14

这是您想要的吗?

每个章节分批,然后是所有单词的数组,这些单词被1000个单词隔开。因此,要访问第一千字,它将是batch [0] [0]。第3章,5000-5999单词 - 批次[2] [4]

batch=[]
for text in chapters:
  print(text)
  text = text.split()
  n = 1000
  batch.append([' '.join(text[i:i+n]) for i in range(0,len(text),n)])  

Is this what you're looking for?

Each chapter is in batch and then within that is an array of all the words separated by 1000 words. So to access the 1st thousand words, it'd be batch[0][0]. Chapter 3, 5000-5999 words - batch[2][4].

batch=[]
for text in chapters:
  print(text)
  text = text.split()
  n = 1000
  batch.append([' '.join(text[i:i+n]) for i in range(0,len(text),n)])  

如何将长字符串列表划分为带有较短字符串的新列表?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文