当前位置:网站首页>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);
边栏推荐
- 关于MySQL主从复制的数据同步延迟问题
- Detailed explanation of the delete problem of ClickHouse delete data
- Be careful with your dictionaries and boilerplate code
- Uni-app 小程序 App 的广告变现之路:激励视频广告
- Qt 同时生成动态库和静态库
- MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
- y82.第四章 Prometheus大厂监控体系及实战 -- 监控扩展和prometheus 联邦(十三)
- Solve npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead
- How strict Typescript strict mode?
- Navicat new database
猜你喜欢
CISP-PTE真题演示
kubernetes
Navicat cannot connect to mysql super detailed processing method
cmd(命令行)操作或连接mysql数据库,以及创建数据库与表
手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践
The Road to Ad Monetization for Uni-app Mini Program Apps: Rewarded Video Ads
数据质量提升
Jetson AGX Orin 平台关于c240000 I2C总线和GMSL ses地址冲突问题
Difference between cookie and session
JS中获取元素属性的8大方法
随机推荐
【翻译】作为混沌网的LFX门徒的经验
Navicat connection MySQL error: 1045 - Access denied for user 'root'@'localhost' (using password YES)
手把手教你搭建一台永久运行的个人服务器
走进Redis,让你重新认识redis。绝不是表面
MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
Be careful with your dictionaries and boilerplate code
基于ABP实现DDD--领域逻辑和应用逻辑
nVisual网络可视化管理平台功能和价值点
How do I refresh the company's background management system (Part 1) - performance optimization
代码越写越乱?那是因为你没用责任链
Niu Ke Xiaobaiyue Race 53 A-E
【信息安全技术】RSA算法的研究及不同优化策略的比较
MySQL Soul 16 Questions, How Many Questions Can You Last?
Uni-app 小程序 App 的广告变现之路:激励视频广告
【高等数学】矩阵与向量组的秩和等价
【菜鸡含泪总结】如何用pip、anaconda安装库
kubernetes
ClickHouse 数据插入、更新与删除操作 SQL
ELF:加载过程
navicat连接MySQL报错:1045 - Access denied for user ‘root‘@‘localhost‘ (using password YES)