当前位置:网站首页>d使用among的问题
d使用among的问题
2022-07-30 21:46:00 【fqbqrr】
import std.stdio;
import std.string;
import std.conv;
import dcollect;
import std.math;
import std.algorithm;
int main(string[] args)
{
int[] x=[23, 34,-88, 54, -90, -34];
auto y=x.filter!(a=>a<0);
foreach(i; y)
i.write(", ");
54.among(to!uint[10](y)).writeln;
return 0;
}
.among用于列表在编译时已知大小或固定的情况.如果是运行时,要用canFind.
if ([1, 2, 3, 4].canFind(3))
writeln("found it!");
或用find
auto r = [ 1, 2, 3, 4 ].find(3);
assert(r.front == 3);
边栏推荐
- Knowledge of C language corners of byte alignment
- ClickHouse 创建数据库建表视图字典 SQL
- openim支持十万超级大群
- TransGAN code reproduction - Jiutian Bisheng Platform
- 拿什么来保护数据安全?基层数据安全体系建设待提升
- MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)
- NEOVIM下载安装与配置
- IDEA 连接 数据库
- 2022/07/30 学习笔记 (day20) 面试题积累
- MySQL 8.0.29 decompressed version installation tutorial (valid for personal testing)
猜你喜欢

CISP-PTE Zhenti Demonstration

8 ways to get element attributes in JS

Automatically generate test modules using JUnit4 and JUnitGenerator V2.0 in IDEA

MYSQL JDBC图书管理系统

A simple rich text editor

我是如何让公司后台管理系统焕然一新的(上) -性能优化

cmd(命令行)操作或连接mysql数据库,以及创建数据库与表

Jetson AGX Orin 平台关于c240000 I2C总线和GMSL ses地址冲突问题

cookie和session区别

Navicat cannot connect to mysql super detailed processing method
随机推荐
It is enough for MySQL to have this article (disgusting typing 37k words, just for Bojun!!!)
小心你的字典和样板代码
Motion Tuned Spatio-temporal Quality Assessmentof Natural Videos
使用LVS和Keepalived搭建高可用负载均衡服务器集群
go慢速入门——函数
ClickHouse to create a database to create a table view dictionary SQL
navicat连接MySQL报错:1045 - Access denied for user ‘root‘@‘localhost‘ (using password YES)
IDEA 连接 数据库
导航栏----个人中心 Dropdown
openim支持十万超级大群
TransGAN代码复现—九天毕昇平台
Solve npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead
ValueError: Append mode is not supported with xlsxwriter解决方案
(7/29) Basic board minimum spanning tree prim+kruskal
数据质量提升
JDBC(详解)
mysql创建表
【导航规划】导航规划背景知识总结
【问题】Mysql Waiting for table metadata lock 解决方案 修改lock_wait_timeout时间
Navicat connection MySQL error: 1045 - Access denied for user 'root'@'localhost' (using password YES)