Many thanks to David for the interest in ordinal fraction arithmetic. I have 
not yet studied the implementation in full detail. Note however that when you 
strip all the zeroes from 3$0 you get 0$0 rather than 1$0.
Allow me some explaining. 
Consider the year number 2020. This year! It is an ordinal number: the 
twothousandandtwentieth year. 
2019 years have passed since the beginning of the calendar. 2019 is a cardinal 
number: twothousandandnineteen years. Note that 2019=2000+0010+0009. Zero means 
"nothing" and the plus sign means  add. You may compute with cardinal numbers, 
but not with ordinal numbers. That is why J'ers use cardinal numbers for 
indexing. 
Increasing each digit in 2019 by one gives 3 1 2 10 indicating that the year 
2020 is the tenth year of the second decade of the first century of the third 
millenium. 
   (4$10)&#:&.<:2020
3 1 2 10

But 10 is not a single digit. In order to avoid the ordinal number 10 we use a 
pental-binary notation.


   (7$5 2)&#:&.<:2020

3 1 1 1 2 2 5

Now separators are superfluous

   10#.(7$5 2)&#:&.<:2020

3111225



meaning  - reading right to left - that the year 2020 is the fifth year of the 
second half of the second decade of the first half of the first century of the 
first half of the third millenium.
Note that 3111225=3000000+0100000+0010000+0001000+0000200+0000020+0000005
This is ordinal fraction arithmetic. It looks like integer arithmetic, but the 
zero means "everything" rather than "nothing", and the plus sign means "and" 
rather than "add". 
The cardinal number 2019 is the algebraic expression    2M+1X+9I = 
2M+0D+0C+0L+1X+1V+4IThe ordinal fraction 3111225 is the logical expression    
M=3, D=1, C=1, L=2, X=2, V=2, I=5The twentyfirst century is 3110000: the first 
century of the first half of the third millenium. And so on. 
Thanks! Bo.
    Den mandag den 27. juli 2020 18.16.27 CEST skrev David Lambert 
<[email protected]>:  
 
 "(Bo's) 1986-article on ordinal fractions may be of interest."
https://www.academia.edu/10031088/ORDINAL_FRACTIONS_-_the_algebra_of_data

Has anyone got an implementation?

Is `=' synonymous with `compatible'? If so, the following seems to work, 
replacing for the literals with a vector.

NB. ordinal fractions, represented by vectors

Dyad=: [: :
Monad=: :[:
Commutes=: adverb def 'assert@:(u -: u~) Dyad'  NB. assertion failure if u does 
not commute

ANY=: , 0
ERROR=: , __
error=: ERROR"_

NB. removes trailing zeros
simplify=: ([: ANY"_^:(0=#) ({.~ (1 i.~([email protected]&=)\.))^:(0={:))"1 Monad

intersect=: dyad define"1
  'X Y'=. x ,:&, y  NB. fill extends the shorter vector
  X=. X + Y * X = 0
  Y=. Y + X * Y = 0
  simplify X error^:(-.@:-:) Y
)

difference=: simplify@:(([ * =)/)@:(,:&,)"1 Dyad


true=: ANY = simplify
eq=: equal=: -:"1 Dyad
incompatible=: (ERROR -: intersect)"1
compatible=: -.@:incompatible
le=: ([ -: intersect)&:,"1
ge=: le~
lt=: subordinate=: le > eq  NB. x subordinate y  proper subset
gt=: superordinate=: ge > eq NB. x superordinate y  proper superset


,.(#~ (1 -.@e.&> ])) <@:(". ::]);._2]0 :0              NB. tests evaluate to 1 
iff pass
  (,3)    -: simplify 3 0 0 0
  ANY      -: simplify ANY
  ANY      -: ANY intersect ANY
  (,1)    -: 1 intersect&:,1
  ERROR    -: 1 intersect&:,2
  ERROR    -: 1 2 3 intersect 1 2 1
  2 3      -: ANY intersect 2 3 0
  0 2 3    -: ANY intersect 0 2 3 0
  2 3      -: 2 3 intersect 2 3 0
  2 3 8    -: 2 3 intersect 2 3 8
              2 3 compatible 2 3 0
              0 2 3 incompatible 2 3 0
              1 [ 2 1 1 1 difference Commutes 2 1 2 1
              1 [ 2 1 0 3 intersect Commutes 0 1 8 3
)


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
  
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to