@JohanL , , Python.
, , Pipe https://github.com/JulienPalard/Pipe .

: . . , . - , . @Pipe , @Pipe , .
, :
rawLabels="""Country: Name of country
Agr: Percentage employed in agriculture
Min: Percentage employed in mining
Man: Percentage employed in manufacturing
PS: Percentage employed in power supply industries
Con: Percentage employed in construction
SI: Percentage employed in service industries
Fin: Percentage employed in finance
SPS: Percentage employed in social and personal services
TC: Percentage employed in transport and communications"""
:
mylabs = "Country Agriculture Mining Manufacturing Power Construction Service Finance Social Transport"
( ):
@Pipe
def split(iterable, delim= ' '):
for s in iterable: yield s.split(delim)
@Pipe
def trim(iterable):
for s in iterable: yield s.strip()
@Pipe
def pzip(iterable,coll):
for s in zip(list(iterable),coll): yield s
@Pipe
def slice(iterable, dim):
if len(dim)==1:
for x in iterable:
yield x[dim[0]]
elif len(dim)==2:
for x in iterable:
for y in x[dim[0]]:
yield y[dim[1]]
@Pipe
def toMap(iterable):
return dict(list(iterable))
:
labels = (rawLabels.split('\n')
| trim
| split(':')
| slice([0])
| pzip(mylabs.split(' '))
| toMap )
:
print('labels=%s' % repr(labels))
labels={'PS': 'Power', 'Min': 'Mining', 'Country': 'Country', 'SPS': 'Social', 'TC': 'Transport', 'SI': 'Service', 'Con': 'Construction', 'Fin': 'Finance', 'Agr': 'Agriculture', 'Man': 'Manufacturing'}
2 2018
https://github.com/dwt/fluent

3 ( 2019 .) : matthagy/scalaps https://github.com/matthagy/scalaps ( , ):
from scalaps import *
a = (Seq(range(1,51))
.map(lambda x: x * 4)
.filter(lambda x: x <= 170)
.filter(lambda x: len(str(x)) == 2)
.filter( lambda x: x % 20 ==0)
.enumerate()
.map(lambda x: 'Result[%d]=%s' %(x[0],x[1]))
.mkstring(' .. '))
print(a)
Result[0]=20 .. Result[1]=40 .. Result[2]=60 .. Result[3]=80