In the same way as if you write int$"abc" and it returns 97 98 99, isit possible to create your own cast to map from one type to another.e.g you have 2 lists, times:10:00:00.000 11:00:00.000 12:00:00.000 andletters:"abc".Is there a way to do something like
letters$times and get a return of"abc".
charset=us-ascii
Message-Id:
Cc: Kdb+ Personal Developers
X-Mailer: iPhone Mail (8C148)
From: Timothy Rieder
Subject: Re: [personal kdb+] customizable casting
Date: Tue, 1 Feb 2011 06:49:56 -0500
To: “personal-kdbplus@googlegroups.com”
It sounds like you more want a dictionary so use that. If that’s not enough u=
se a lambdas. You could also use a dictionary of lambdas:letters
foo!({cast to letters};{cast to foo})
I’m not sure that can be applied to what I really want.I have a table: | sym |times | ____________________________ | | ibm | 21:00:00.00005:00:00.000 | | goog| 03:00:00.000 09:00:00.00005:00:00.000 |if I did "update int$times from table" it returns | sym |times | \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ | | ibm | 75600000180000000 | | goog| 10800000 3240000000180000000 |But I don't want ints, I want to be able to map the times onto lettersof my choiceOn Feb 1, 11:49?am, Timothy Rieder <trie...> wrote:> It sounds like you more want a dictionary so use that. If that's not enough use a lambdas. You could also use a dictionary of lambdas:>>
lettersfoo!({cast to letters};{cast to foo})>> On Feb 1, 2011, at 5:14 AM, Conor <omearaco...> wrote:>> > In the same way as if you write
int$“abc” and it returns 97 98 99, is> > it possible to create your own cast to map from one type to another.> > e.g you have 2 lists, times:10:00:00.000 11:00:00.000 12:00:00.000 and> > letters:“abc”.>> > Is there a way to do something like `letters$times and get a return of> > “abc”.>> > –> >
Submitted via Google Groups</omearaco…></trie…>
That displayed awful tables should look likesym timeibm 21:00:00.000 05:00:00.000goog 03:00:00.000 09:00:00.000 05:00:00.000sym timeibm 75600000 180000000goog 10800000 324000000 180000000On Feb 1, 12:11?pm, Conor <omearaco…> wrote:> I’m not sure that can be applied to what I really want.> I have a table: ?| sym |> times ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|>> ____________________________? ? ? ? ? ? ? ? ? ? ? ? ? ?|> ? ? ? ? ? ? ? ? ? ? ? | ibm ?| 21:00:00.000> 05:00:00.000 ? ? ? ? ? ? ? ? ? ? ? ? ? ?|> ? ? ? ? ? ? ? ? ? ? ? | goog| 03:00:00.000 09:00:00.000> 05:00:00.000 ? ? ? ? |>> if I did "update int$times from table" it returns> ? ? ? ? ? ? ? ? ? ? ? ?| sym |> times ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|>>____________________________? ? ? ? ? ? ? ? ? ? ? ? ? ?|> ? ? ? ? ? ? ? ? ? ? ? | ibm ?| 75600000> 180000000 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|> ? ? ? ? ? ? ? ? ? ? ? | goog| 10800000 3240000000> 180000000 ? ? ? ? ? ? ? ? |>> But I don't want ints, I want to be able to map the times onto letters> of my choice>> On Feb 1, 11:49?am, Timothy Rieder <trie...> wrote:>> > It sounds like you more want a dictionary so use that. If that's not enough use a lambdas. You could also use a dictionary of lambdas:>> >
lettersfoo!({cast to letters};{cast to foo})>> > On Feb 1, 2011, at 5:14 AM, Conor <omearaco...> wrote:>> > > In the same way as if you write
int$“abc” and it returns 97 98 99, is> > > it possible to create your own cast to map from one type to another.> > > e.g you have 2 lists, times:10:00:00.000 11:00:00.000 12:00:00.000 and> > > letters:“abc”.>> > > Is there a way to do something like `letters$times and get a return of> > > “abc”.>> > > –> > >
Submitted via Google Groups</omearaco…></trie…></omearaco…>
On Feb 1, 2011, at 7:16 AM, Conor wrote:
> That displayed awful tables should look like
>
> sym time
> ibm 21:00:00.000 05:00:00.000
> goog 03:00:00.000 09:00:00.000 05:00:00.000
>
> sym time
> ibm 75600000 180000000
> goog 10800000 324000000 180000000
cast is just a function, you can plug anything you like into that update
statement
here’s an example using a dictionary to map times by hour onto a-x
q)t:(sym:ibm
goog;time:(21:00:00.000 05:00:00.000;03:00:00.000
09:00:00.000 05:00:00.000))
q)d:(01:00:00.0*til 24)!`$'“c”$(“i”$“a”)+til 24
q)t
sym time
ibm 21:00:00.000 05:00:00.000
goog 03:00:00.000 09:00:00.000 05:00:00.000
q)d
00:00:00.000| a
01:00:00.000| b
02:00:00.000| c
03:00:00.000| d
04:00:00.000| e
05:00:00.000| f
06:00:00.000| g
07:00:00.000| h
08:00:00.000| i
09:00:00.000| j
10:00:00.000| k
11:00:00.000| l
12:00:00.000| m
13:00:00.000| n
14:00:00.000| o
15:00:00.000| p
16:00:00.000| q
17:00:00.000| r
18:00:00.000| s
19:00:00.000| t
20:00:00.000| u
21:00:00.000| v
22:00:00.000| w
23:00:00.000| x
q)update d time from t
sym time
ibm v
f
goog d
j`f