compacting an expression

29 views
Skip to first unread message

Jack Andrews

unread,
Apr 11, 2012, 8:34:47 AM4/11/12
to Kdb+ Personal Developers
can this expression be written in fewer characters?
  (33+!7),42+!84

what about this one?
  (20+!8),(33+!7),42+!84

ta, jack

kuentang

unread,
Apr 11, 2012, 9:21:41 AM4/11/12
to Kdb+ Personal Developers

I assume that the espression is in K and not in Q.
My more compact solution would be

,/(33 42)+!:'7 8

Attila Vrabecz

unread,
Apr 11, 2012, 5:36:04 PM4/11/12
to personal...@googlegroups.com
.c.e:#:
c)(33+!7),42+!84
14
c)(33+!93)_/7 7
13
c)(20+!8),(33+!7),42+!84
22
c)(20+!106)_/(5#8),2#15
21

But I doubt that this is what you were looking for ;)

Cheers,
Attila

> --
> You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
> To post to this group, send email to personal...@googlegroups.com.
> To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.

Aaron Davies

unread,
Apr 12, 2012, 11:01:12 AM4/12/12
to personal...@googlegroups.com
parens aren't needed

,/33 42+!:'7 84

handles the other one two

,/20 33 42+!:'8 7 84

> --
> You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
> To post to this group, send email to personal...@googlegroups.com.
> To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.
>

--
Aaron Davies
aaron....@gmail.com

Jack Andrews

unread,
Apr 14, 2012, 8:02:49 AM4/14/12
to personal...@googlegroups.com
Thanks kuentang, aaron,

does : mean "monadic" so !: in your expressions mean "monadic !"?

Attila Vrabecz

unread,
Apr 14, 2012, 8:08:52 AM4/14/12
to personal...@googlegroups.com
correct
you only need the : if there is no data or verb right next to it
so for example
in !10 ! is monadic
but if you would say
f:!:
l:(!:;.:) /for key and value
or do something like
!:'1 2 3
-:\1 2 3
you need the :

Cheers,
Attila

Reply all
Reply to author
Forward
0 new messages