From 3250ac1188e9fc0e38231e1b5267c5e35d7dcfd6 Mon Sep 17 00:00:00 2001 From: Alex Cheng Date: Tue, 19 Nov 2019 19:32:40 -0800 Subject: [PATCH] replace list comprehension with map function --- 03-arrays/tf-03.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/03-arrays/tf-03.py b/03-arrays/tf-03.py index 96903bc..bf79ef6 100644 --- a/03-arrays/tf-03.py +++ b/03-arrays/tf-03.py @@ -30,11 +30,11 @@ w_ranges = w_ranges[np.where(w_ranges[:, 1] - w_ranges[:, 0] > 1)] # [ 7, 13]], dtype=int64) # Voila! Words are in between spaces, given as pairs of indices -words = [characters[w_ranges[i][0] : w_ranges[i][1]] for i in range(len(w_ranges))] +words = list(map(lambda r: characters[r[0]:r[1]], w_ranges)) # Result: [array([' ', 'h', 'e', 'l', 'l', 'o'], dtype='