Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

help List with block and occurrence

 [1/2] from: lp::legoff::free::fr at: 22-Jan-2004 17:53


hi rebolers ! Needs help for a little piece of code : I call in a foreach loop some datas from a block : foreach [name date hour remark] my-structured-block [ .... ] datas in block looks like : user1 01-01-2004 08:07 test1 user1 01-01-2004 08:02 test2 user1 01-01-2004 08:04 test3 user2 01-01-2004 08:10 testx user2 02-01-2004 10:11 testn user1 02-01-2004 11:25 testi user3 02-01-2004 12:48 testj .... not regular ... I want to get after my loop result (block ? array ??) by day, and classified by unique names and number of occurrence with them like : 01-01-2004 [ user1 3 user2 1] 02-02-2004 [ user1 1 user2 1 user3 1] Is someone could help me ? Thanks, Philippe

 [2/2] from: greggirwin:mindspring at: 22-Jan-2004 10:50


Hi Philippe, llff> datas in block looks like : llff> user1 01-01-2004 08:07 test1 llff> ... llff> I want to get after my loop result (block ? array ??) by day, llff> and classified by unique names and number of occurrence with llff> them like : llff> 01-01-2004 [ user1 3 user2 1] llff> 02-02-2004 [ user1 1 user2 1 user3 1] Something like this? tally: func [data /local result pos] [ result: copy [] emit: func [date name] [ if not find/skip result date 2 [ repend result [date copy reduce [name 0]] ] either pos: find/skip result/:date name 2 [ change next pos add 1 result/:date/:name ][ repend result/:date [name 1] ] ] foreach [name date time note] data [emit date name] result ] -- Gregg