Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #52872

Grouping elements of an array

From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.forth
Subject Grouping elements of an array
Date 2016-11-25 16:27 +0000
Organization Aioe.org NNTP Server
Message-ID <o19ooj$t5i$1@gioia.aioe.org> (permalink)

Show all headers | View raw


Ruby:

def pred_collect(list, *lambdas)
  list.group_by{|n| lambdas.index{|lambda| lambda[n]} or lambdas.size }.
  sort.map &:last
end

pred_collect [-5,-4,-3,-2,-1,0,1,2,3,4,5],
  ->n{n.even?}, ->n{n < 0}, ->n{n > 3}

 ===>
[[-4, -2, 0, 2, 4], [-5, -3, -1], [5], [1, 3]]

In Forth?

-- 
The major media are controlled and run by Jews. They want White people dead,
replaced, mixed and immigrated and migrated and refugeed out of existence.
Telling the truth about racially-motivated attacks on Whites by Blacks does not
fit their agenda.
nationalvanguard.org/2016/10/how-can-we-stop-the-mystery-attacks/

Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread


Thread

Grouping elements of an array "Robert L." <No_spamming@noWhere_7073.org> - 2016-11-25 16:27 +0000

csiph-web