Mind / Matter
things that count
DN Logo



Click here to send an email. DN
Click here to send an email. SOK


-11703
213233
K: Best (Known so far) Practice

The purpose of this note is to accumulate questions and answers about how to perform certain systems oriented tasks in K. I can make no particular claims that the information presented is particularly effective, but it has at least been vetted by the concern of some programmers who have shared their suggestions and corrections.

DN Variable Detection How do you detect he presence or absence of a variable without causing an error? I
(1)
. `sym
Appears to produce value of str in current directory or null
DN
(2)
d`str
Same, so long as d exists
SA
(3)
.[d;`str;:]
Doesn't seem to have any paricular advantage / disadvantage over (2)
GH
(4)
(#!_d)~(!_d)?`str
Allows distinguishing `defined but null' from `not defined'
GH

Conclusion
Not Yet Established

DN Directories How do you select Directories from a list of files? II
(1)
f@&~(@!:)'f
Given list of files f shows Dirs (Links?)
EL,SA

Conclusion
Not Yet Established

DN File Characteristics How can you get file attributes in a K program? III
(1)
Code is Here
An approach using the Windows DIR command has been coded for NT, ME, 98 and Win2K
DN

Conclusion
Not Yet Established

DN Windows Version How can you figure out which Windows is running in a K program? IV
(1)
Code is Here
The ver function returns which Windows Version is running.
DN

Conclusion
Not Yet Established

DN Enlist a Scalar How can you `enlist' a scalar without enlisting a list in K program? V
(1)
V:{:[@x;,x;x]}
If x is an atom enlist it, otherwise leave it alone
BA
(2)
l,()
Appending a null list leaves list alone, but converts scalar to list
SS

Conclusion
(2) looks hard to beat. No disadvantages have been reported yet.

DN Iterators How can you see the effect of K's interators? VI
(1)
Code is Here
Shows the effect of the execution of K's interators.
DN

Conclusion
Not Yet Established

Contributors
Who
Name
Home Page
Mail To
SA
Stevan Apter

sapter@earthlink.net
BA
Bob Armstrong
www.cosy.com
bob@cosy.com
GH
Greg Heil
www.scn.org/tl/anvil
gheil@scn.org
EL
Eberhard Lutz
www.e7l3.com/
elutz@e7l3.com
DN
David Ness
mywebpages.comcast.net/dness
DNess@Comcast.Net
SS
Sandy Steier

sandy.steier@1010data.com



© Copyright 2002 David Ness.
Last update: 2002-12-17 16:32:33 EST