a:b:cd:e is a list of 4 values
/given a string
x:“de”
/and strings
y:(“a:b:cd:e”;“”;“bc:de:f”)
f: put x at the front of a list, removing any occurrence of x the list.
so the result of feach y should be
(“de:a:b:cd:e”;“de”;“de:bc:f”)
further, “a::b” is a punctuation error and is the same as “a:b”
a fault tolerant f should give
f[“b”;“a::b”]
“b:a”
Hi Jack,
Curious as to the bigger picture here and what kind of problem you are trying to solve. These small problems always turn out to be interesting.
I am sure there are more complexities within the bigger picture too, but below is one solution:
q)x:“de”
q)y:(“a:b:cd:e”;“”;“bc:de:f”)
q)f:{“:” sv y 0,where not any (y:“:” vs x,“:”,y)~:/:(x:raze x;“”)}
q)f[“b”;“a::b”]
“b:a”
q)f[“de”]each y
“de:a:b:cd:e”
“de”
“de:bc:f”
Sean
hi sean,
the problem i was trying to solve is manipulating getenv `PATH
it’s interesting how writing an email to describe a problem actually helps solve it!
after a break, this came to me:
q)x:“de”
q)y:(“a:b:cd:e”;“”;“bc:de:f”)
q)f:{“:“sv enlist,(s:”:“vs y) except (””;x)}
q)feach y
“de:a:b:cd:e”
“de”
“de:bc:f”
f[1#“b”;“a::b”] /cheated on the atom case
“b:a”