Post Reply 
Programming puzzles: processing lists!
06-05-2017, 02:54 PM (This post was last modified: 06-05-2017 03:00 PM by pier4r.)
Post: #122
RE: Programming puzzles: processing lists!
Added the #31 that I thought I already introduced (instead the #30 is part of it).

I solved it making use of a previous release of the David's library (I could not find an updated version with all the listed commands).

From 0 to users it is quick if the product is usable.

My (slow but useful) solution to #31 (more info: )

  @ works
    @input: a list

L1: a list on elements of which we want to calculate the frequency in the list itself

L3: the original list, sorted ascending, with no duplicates
L2: the frequencies of the elements in the original list.
L1: the matrix containing the two lists as columns for possible stats operations

in: { 3 2 1 3 2 1 2 1}

Out: {1 2 3} { 3 3 2} [ [1 3] [2 3] [3 2] ]

- it requires the list library done by davidM
check's forum topic keywords 'processing lists!'
      0                "inListSize" DROP
      {}             "resListNoDup" DROP
      {}              "resListFreq" DROP
      @local var
        inList SORT LDDUP 'resListNoDup' STO
        @counting the frequency now.
          inList SWAP LCNT
            @ we count the number of times the element was in the input
            @ list
        'resListFreq' STO
        @making the matrix
        resListNoDup list2array
        resListFreq list2array

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: Programming puzzles: processing lists! - pier4r - 06-05-2017 02:54 PM

User(s) browsing this thread: 1 Guest(s)