[Jprogramming] How many years did each person live?

Linda A Alvord lindaalvord at verizon.net
Thu Jun 30 02:54:49 UTC 2016


I first used the data in Outlook and search by date, or name and then rearrange rows based on order of columns.  However I first thought I'd do this in Excel, but I don't know it well enough to know how to do it.  I could get the ages, but...  SO, I turned to J.  

Your example is another interesting example.  I'm also wondering what would be an example that students would like.  My guess for some, a baseball example might work.

Linda

-----Original Message-----
From: Programming [mailto:programming-bounces at forums.jsoftware.com] On Behalf Of David Lambert
Sent: Wednesday, June 29, 2016 10:04 AM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] How many years did each person live?

This is a similar problem I solve with j.


The chess game with greatest rating difference may be most fun to observe.
Goal: find the game number having greatest absolute value of rating difference.

First column is game number.  (noun A)
Second and fourth columns are player ratings.


The alphabetical nouns are in order of the steps.
Some data


    A=: 0 :0  NB. some data
  21 2668 GMNisipeanu 2643 GMIvanisev [ su120   0] 1:53:32 -1:46:26 
(36-36) B:  9
263 2626 GMAlekseev  2691 GMMatlakov [ su120   0] 1:15:36 -1:37:24 
(34-34) W: 13
115 3004 COMPAndscac 3123 COMPGull   [ su120   0] 1:14:06 - 54:06 
(35-32) B: 23
)


    NB. B looks much like Linda's data
    [B =: ;:;._2 A
+--------+-----------+----+----------+-+-----+-+-+--+---+--+-+---+---+--+--+--+--+--+--+--+--+
|21 2668 |GMNisipeanu|2643|GMIvanisev|[|su120|0|]|1:|53:|32|-|1: 
|46:|26|( |36|- |36|) |B:|9 |
+--------+-----------+----+----------+-+-----+-+-+--+---+--+-+---+---+--+--+--+--+--+--+--+--+
|263 2626|GMAlekseev |2691|GMMatlakov|[|su120|0|]|1:|15:|36|-|1: 
|37:|24|( |34|- |34|) |W:|13|
+--------+-----------+----+----------+-+-----+-+-+--+---+--+-+---+---+--+--+--+--+--+--+--+--+
|115 3004|COMPAndscac|3123|COMPGull |[|su120|0|]|1:|14:|06|-|54:|06 |(
|35|- |32|) |B:|23|  |
+--------+-----------+----+----------+-+-----+-+-+--+---+--+-+---+---+--+--+--+--+--+--+--+--+


    NB. C is numeric
    [C =: _".&.> 0 2 {"1 B
+--------+----+
|21 2668 |2643|
+--------+----+
|263 2626|2691|
+--------+----+
|115 3004|3123|
+--------+----+


    NB. D is easy to work with
    [D =: ;"1 C
  21 2668 2643
263 2626 2691
115 3004 3123


    NB. E are the rating differences,
    [E =: ([: | [: -/ }.)"1  D
25 65 119


    NB. game numbers ordered by rating differences
    D/:E
  21 2668 2643
263 2626 2691
115 3004 3123


    NB. rows of original data ordered by rating differences
    ([;._2 A) /: E
  21 2668 GMNisipeanu 2643 GMIvanisev [ su120   0] 1:53:32 -1:46:26 
(36-36) B:  9
263 2626 GMAlekseev  2691 GMMatlakov [ su120   0] 1:15:36 -1:37:24 
(34-34) W: 13
115 3004 COMPAndscac 3123 COMPGull   [ su120   0] 1:14:06 - 54:06 
(35-32) B: 23


Conclusion: observe game 115, which happens to be a match in the current Top Chess Engine Championship.
Data from http://www.freechess.org/
TCEC at http://tcec.chessdom.com/live.php

> On Wed, Jun 29, 2016 at 12:45 PM, Linda A 
> Alvord<lindaalvord at verizon.net>
> wrote:
>
>> >Nowdefine a verb to add a 4th column of the life span of each person.
>> >
>> >
>> >
>> >A=:'1809';'Philip St. George Cooke';'1895'
>> >
>> >    B=:'1836';'Flora Cooke Stuart';'1923'
>> >
>> >    C=:'1833';'Jeb Stuart';'1864'
>> >
>> >    D=:'1834';'Jacob Sharpe';'189'
>> >
>> >    [E=:A,B,C,:D
>> >
>> >-----T-----------------------T----┐
>> >│1809│Philip St. George Cooke│1895│
>> >+----+-----------------------+----+
>> >│1836│Flora Cooke Stuart     │1923│
>> >+----+-----------------------+----+
>> >│1833│Jeb Stuart             │1864│
>> >+----+-----------------------+----+
>> >│1834│Jacob Sharpe           │189 │
>> >L----+-----------------------+-----
>> >

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



More information about the Programming mailing list