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: https://app.assembla.com/spaces/various-...stics101.s )
Code:

list2array
  @ works
  \<<
    @input: a list
    
    OBJ\->
    \->ARRY
  \>>

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

output:
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

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

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

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

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)