Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakudo: initial implementation of 'map' #91

Closed
p6rt opened this issue May 22, 2008 · 7 comments
Closed

Rakudo: initial implementation of 'map' #91

p6rt opened this issue May 22, 2008 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 22, 2008

Migrated from rt.perl.org#54642 (status was 'resolved')

Searchable as RT54642$

@p6rt
Copy link
Author

p6rt commented May 22, 2008

From @bacek

Hello

There is attached initial implementation of map.

--
Bacek.

@p6rt
Copy link
Author

p6rt commented May 22, 2008

From @bacek

map.diff
Index: src/classes/List.pir
===================================================================
--- src/classes/List.pir	(revision 27739)
+++ src/classes/List.pir	(working copy)
@@ -670,6 +670,39 @@
     .return 'list'(arr)
 .end
 
+=item map()
+
+Map.
+
+=cut
+
+.sub 'map' :method
+    .param pmc expression
+    .local pmc res, elem, mapres, newitem
+    .local int len, i
+
+    res = new 'List'
+    len = elements self
+    i = 0
+  loop:
+    if i == len goto done
+    elem = self[i]
+    inc i
+    mapres = expression(elem)
+
+    # flatten mapres
+    mapres = 'list'(mapres) 
+  copy_loop:
+    unless mapres goto loop
+    newitem = shift mapres
+    res.'push'(newitem)
+    goto copy_loop
+
+
+  done:
+
+    .return(res)
+.end
 =back
 
 =head1 Functions
@@ -729,6 +762,22 @@
 .end
 
 
+=item C<map>
+
+Operator form of C<map>. Creates List and delegates map to it.
+
+=cut
+
+.sub 'map'
+    .param pmc expression 
+    .param pmc args :slurpy
+    .local pmc l
+
+    l = 'list'(args :flat)
+    .return l.'map'(expression)
+.end
+
+
 =item C<infix:,(...)>
 
 Operator form for building a list from its arguments.
@@ -1079,8 +1128,9 @@
     .return list.'uniq'()
 .end
 
-## TODO: join map reduce sort zip
 
+## TODO: map zip
+
 =back
 
 =cut
@@ -1090,3 +1140,4 @@
 #   fill-column: 100
 # End:
 # vim: expandtab shiftwidth=4 ft=pir:
+

@p6rt
Copy link
Author

p6rt commented May 22, 2008

From @bacek

On Thu May 22 05​:39​:39 2008, bacek wrote​:

Hello

There is attached initial implementation of map.

Reimplemented version after discussion on #parrot

--
Bacek

@p6rt
Copy link
Author

p6rt commented May 22, 2008

From @bacek

map.diff
Index: src/classes/List.pir
===================================================================
--- src/classes/List.pir	(revision 27739)
+++ src/classes/List.pir	(working copy)
@@ -670,6 +670,30 @@
     .return 'list'(arr)
 .end
 
+=item map()
+
+Map.
+
+=cut
+
+.sub 'map' :method
+    .param pmc expression
+    .local pmc res, elem, mapres, iter
+
+    res = new 'List'
+    iter = new 'Iterator', self
+  loop:
+    unless iter goto done
+    elem = shift iter
+    mapres = expression(elem)
+
+    res.'push'(mapres)
+    goto loop
+
+  done:
+    .return(res)
+.end
+
 =back
 
 =head1 Functions
@@ -729,6 +753,22 @@
 .end
 
 
+=item C<map>
+
+Operator form of C<map>. Creates List and delegates map to it.
+
+=cut
+
+.sub 'map'
+    .param pmc expression 
+    .param pmc args :slurpy
+    .local pmc l
+
+    l = 'list'(args :flat)
+    .return l.'map'(expression)
+.end
+
+
 =item C<infix:,(...)>
 
 Operator form for building a list from its arguments.
@@ -1079,8 +1119,9 @@
     .return list.'uniq'()
 .end
 
-## TODO: join map reduce sort zip
 
+## TODO: zip
+
 =back
 
 =cut

@p6rt
Copy link
Author

p6rt commented May 22, 2008

@bacek - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 23, 2008

From @bacek

Obsoleted by #​54742

@p6rt
Copy link
Author

p6rt commented May 23, 2008

@bacek - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed May 23, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant