1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/timandy-linq

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
README_CN.md 2.1 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
gitlife-traslator Отправлено 28.11.2024 11:01 425a72c

Где (x -> x != null && x.length() > 0) — агрегация с использованием функции (x, y) -> x + ", " + y.

System.out.println(result);

Проверка всех положительных чисел на чётность.

boolean result = Linq.of(9999, 0, 888, -1, 66, -777, 1, 2, -12345)
        .where(x -> x > 0)
        .all(x -> x % 2 == 0);

System.out.println(result);
----
false

Проверка наличия хотя бы одного чётного числа среди положительных.

boolean result = Linq.of(9999, 0, 888, -1, 66, -777, 1, 2, -12345)
        .where(x -> x > 0)
        .any(x -> x % 2 == 0);

System.out.println(result);
----
true

Добавление числа в конец и вставка двух чисел в начало последовательности.

String result = Linq.range(3, 2).append(5).prepend(2).prepend(1).format();

System.out.println(result);
----
[1, 2, 3, 4, 5]

Вычисление среднего значения последовательности целых чисел.

double result = Linq.of(5, -10, 15, 40, 28).averageInt();

System.out.println(result);
----
15.6

Объединение двух последовательностей целых чисел.

String result = Linq.of(1, 2).concat(Linq.of(3, 4)).format();

System.out.println(result);
----
[1, 2, 3, 4]

Лицензия

LINQ to Objects (Java) распространяется под лицензией Apache License 2.0.

Copyright 2017-2024 济南百思为科信息工程有限公司

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/timandy-linq.git
git@api.gitlife.ru:oschina-mirror/timandy-linq.git
oschina-mirror
timandy-linq
timandy-linq
master