当前位置:网站首页>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);
边栏推荐
- 微信公众号授权登录后报redirect_uri参数错误的问题
- 小心你的字典和样板代码
- How strict Typescript strict mode?
- JDBC(详解)
- navicat连接MySQL报错:1045 - Access denied for user ‘root‘@‘localhost‘ (using password YES)
- openim支持十万超级大群
- navicat新建数据库
- TransGAN code reproduction - Jiutian Bisheng Platform
- When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
- MySQL 5.7详细下载安装配置教程
猜你喜欢
关于MySQL主从复制的数据同步延迟问题
kubernetes
解决centos8 MySQL密码问题ERROR 1820 (HY000) You must reset your password using ALTER USER
类和对象——上
MySQL cursors
MySQL compressed package installation, fool teaching
牛客小白月赛53 A-E
MySQL 5.7详细下载安装配置教程
The Road to Ad Monetization for Uni-app Mini Program Apps: Rewarded Video Ads
Solve npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead
随机推荐
MySQL 5.7详细下载安装配置教程
MySQL 8.0.29 解压版安装教程(亲测有效)
1064 Complete Binary Search Tree
数据质量提升
MySQL compressed package installation, fool teaching
MySQL 8.0.29 设置和修改默认密码
MYSQL JDBC图书管理系统
鳄梨价格数据集(Avocado Prices)
mysql创建表
手把手教你搭建一台永久运行的个人服务器
Union, the difference between union and structure, the knowledge of enumeration of C language corners
cnpm的安装与使用
Navicat new database
The Road to Ad Monetization for Uni-app Mini Program Apps: Rewarded Video Ads
The most powerful and most commonly used SQL statements in history
基于ABP实现DDD--仓储实践
When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
cookie和session区别
【零代码工具】15 款企业级零代码开发平台推荐,总有一款是你心仪的
TransGAN代码复现—九天毕昇平台