项目作者: magicxor

项目描述 :
LINQ for Delphi (Object Pascal)
高级语言: Pascal
项目地址: git://github.com/magicxor/MapReduce.git
创建时间: 2015-08-20T04:12:34Z
项目社区:https://github.com/magicxor/MapReduce

开源协议:Apache License 2.0

下载


MapReduce / ArrayLinq

build

LINQ for Delphi (Object Pascal)

TArrayContainer<T> contains methods that use higher-order functions to perform some tasks:

Every, Some, Filter, Map, FlatMap, Reduce, ForEach, Order, FirstOrDefault

(LINQ analogs: All, Any, Where, Select, SelectMany, Aggregate, ForEach, OrderBy, FirstOrDefault)

Usage

  1. myPet := TArrayContainer<TCat>
  2. .Create([TCat.Create('Tiger', 10, 'black', True),
  3. TCat.Create('Kitty', 7, 'ginger', True),
  4. TCat.Create('Simba', 9, 'white', True),
  5. TCat.Create('Barsik', 6, 'gray', False),
  6. TCat.Create('Sam', 8, 'white', True),
  7. TCat.Create('Musya', 5, 'black', True)])
  8. .Filter(function(const x: TCat): boolean begin exit((x.Weight > 5) and (x.HasTail)); end)
  9. .Map<string>(function(const x: TCat): string begin exit(x.Name); end)
  10. .Order()
  11. .FirstOrDefault(function(const x: string): boolean begin exit(x.StartsWith('S')) end);
  12. Writeln('Your pet is ' + myPet); // Sam

Compilation guide

In order to compile this code on Windows, you need to install the Embarcadero RAD Studio XE8 (or higher).

See also: RAD Studio docker images