当前位置:网站首页>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);
边栏推荐
- 【Nacos】解决Nacos下载速度缓慢的问题
- Union, the difference between union and structure, the knowledge of enumeration of C language corners
- 1064 Complete Binary Search Tree
- kubernetes
- Navicat connection MySQL error: 1045 - Access denied for user 'root'@'localhost' (using password YES)
- IDEA2021.2安装与配置(持续更新)
- 基于ABP实现DDD--领域服务、应用服务和DTO实践
- (7/29) Basic board minimum spanning tree prim+kruskal
- JUC原子类详解
- openim支持十万超级大群
猜你喜欢

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

Difference between cookie and session

c语言进阶篇:指针(五)

ClickHouse 数据插入、更新与删除操作 SQL

cmd (command line) to operate or connect to the mysql database, and to create databases and tables

When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'

ClickHouse to create a database to create a table view dictionary SQL

MySQL 8.0.29 set and modify the default password

MySQL压缩包方式安装,傻瓜式教学

Navicat connection MySQL error: 1045 - Access denied for user 'root'@'localhost' (using password YES)
随机推荐
MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
设备树的引入与体验
When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
系统结构考点之并行计算霍纳法则
CISP-PTE真题演示
MySQL 有这一篇就够(呕心狂敲37k字,只为博君一点赞!!!)
数据质量提升
系统结构考点之流水线向量点积
nVisual网络可视化管理平台功能和价值点
MySQL 8.0.29 解压版安装教程(亲测有效)
Advanced c language: pointers (5)
ELF: Loading process
我是如何让公司后台管理系统焕然一新的(上) -性能优化
LeetCode · 23. Merge K ascending linked lists · recursion · iteration
About the error of SFML Rect.inl file
类似 MS Project 的项目管理工具有哪些
How strict Typescript strict mode?
openim支持十万超级大群
Collapse legacy apps
MySQL 用户授权