This is a predicate that is supposed to write backwards out of a list, but since 'tab(-2)' doesn't work I was wondering if there are other predicates, or a different way of using'tab/1' in order to move backwards.
(Using 'reverse/2' is not an option in this case).
Im fairly new to all this, so I hope I did everything right, any kind of help would be appreciated.
snakeprint([X|Xs],Counter1,Counter2,Y,2):-
tab((Y*3)-3),
write(X),
tab(-2),
C1 is Counter1-1,
snakeshift([X|Xs],V),
snakeprint(V,C1,Counter2,Y,2).
snakeprint([H|T]) :-
snakeprint(T),
write(H).
snakeprint([]).
Input: ["M", "a", "r", "y", " ", "h", "a", "d"]
Output: dah yraM
Related
Given these lines of code:
let order = cts.indexOrder(cts.elementReference(fn.QName('','order')))
cts.search(cts.jsonPropertyValueQuery('order','*', ['wildcarded'] ),order)
I get this result:
{"order":["a", "m"]}
{"order":"a"}
{"order":["a", "x"]}
{"order":"j"}
{"order":["j", "k", "l"]}
{"order":["j", "k"]}
{"order":["j", "k", "m"]}
{"order":"m"}
{"order":["m", "z"]}
Shouldn't ["a"] sort before ["a","m"], and ["j","k"] precede ["j","k","l"]?
It seems like there is some kind of ordering, but it's not precise in this way, and I'd like to understand the rules, as we have exactly this situation in a project I'm working on.
attribute=( a b c )
I need the array to be held in a variable and show like so:
"a" , "b" , "c"
I suspect this is an XY Problem and you should really be asking about what you want as an end result rather than this micro-issue, but to answer the question you asked -
$: for a in "${attribute[#]}"; do str+="\"$a\" , ";done; str="${str% , }"
$: echo "[$str]"
["a" , "b" , "c"]
For the record, this is probably a bad idea.
Please consider editing your OP to discuss what you want to accomplish and what you have tried. Someone can almost certainly give you a better, safer, smarter solution.
i have conditions in my elasticsearch documents, for example:
{
...
"conditions": [
{
"required": ["a"],
"prohibited": ["f"]
},
{
"required": ["a", "b"],
"prohibited": ["c", "d"]
}
]
}
And a have a dataset, for example ["a", "b", "f"] (a true example, because second condition matches)
Now I want to write a Elasticsearch-Query that returns all documents to which the conditions apply to my dataset. The tricky part which i am hanging on is not to loose the single conditions relations. All entries in required have to match in combindation and with prohibited it's the same.
Hope there is a es-specialist who can give me an approach what the best way is to solve this challenge. At the moment i think on a Script-Query or different structure of these conditions in our documents. But maybe there is a way (which i don't see) to formulate this as normal ES-Query.
After a lot of tries and frustration i decided to solve my problem with a painless script. It's not perfect from a performance point of view but it works.
I have datasets that consist of arrays and single values
{
"a": "18",
"b": ["x","y","z"]
}
or arrays and arrays
{
"a": ["g", "h", "i"],
"b": ["x", "y", "z"]
}
and i plan to map out each combination (like "18-x", "18-y", "18-z" or "g-x", "g-y"...) to count these afterwards (or do anything else). I'm used to CouchDB with their emit function: I simply emitted multiple combinations per document. How is this supposed to be done in RethinkDB?
Note: The datasets are produced by a join
I would recommend making both fields always be arrays, even if the arrays sometimes only have a single value.
If you do that, you can do this with concat_map:
row('a').concatMap(function(a){
return row('b').map(function(b){
return a.add('-').add(b);
});
});
If you want to continue using a mix of single values and arrays, you can do that by replacing r.row('a') with r.branch(r.row('a').typeOf().eq('ARRAY'), r.row('a'), [r.row('a')]).
I have been trying a simple Ruby program to parse a simple pdf file and extract the texts I am interested in. I found that pdf-reader is quite good gem for pdf file parsing. I have read through the examples given in that gem and some tutorials around that.
I have tried the callback method and was able to get all the text from my pdf file. But I did not understand the concept behind the arguments for some of the callbacks.
For example, If my pdf has a simple table with 3 columns and 2 rows. (Header row values are Name, Address, Age) and first row values are (Arun, Hoskote, 22) and when U run the a ruby following ruby script
receiver = PDF::Reader::RegisterReceiver.new
reader = PDF::Reader.new("Arun.pdf")
reader.pages.each do |page|
page.walk(receiver)
receiver.callbacks.each do |cb|
puts cb.inspect
end
end
It prints series of callbacks among which some of the interesting callbacks show_text_with_positioning were like following
{:name=>:show_text_with_positioning, :args=>[["N", 5, "am", -4, "e"]]}
{:name=>:show_text_with_positioning, :args=>[[" "]]}
{:name=>:show_text_with_positioning, :args=>[["Ad", 6, "d", 3, "ress"]]}
{:name=>:show_text_with_positioning, :args=>[[" "]]}
{:name=>:show_text_with_positioning, :args=>[["Age"]]}
{:name=>:show_text_with_positioning, :args=>[[" "]]}
{:name=>:show_text_with_positioning, :args=>[["Ar", 4, "u", 3, "n"]]}
{:name=>:show_text_with_positioning, :args=>[[" "]]}
{:name=>:show_text_with_positioning, :args=>[["H", 3, "o", -5, "sk", 9, "o", -5, "te"]]}
{:name=>:show_text_with_positioning, :args=>[[" "]]}
{:name=>:show_text_with_positioning, :args=>[["22"]]}
{:name=>:show_text_with_positioning, :args=>[[" "]]}
From the above callbacks, what does args represent with respect to pdf file ? If I want to extract only name value that is 'Arun' (Anything can come here) here or age value i,e '25' (any value can come here) here in this example, how can I do that in ruby program ? Is there any pdf-parser API or Ruby API to get only a single "interested" value(s) from a pdf file ?
How can I write a Ruby program to access a particular callback which I am interested in which gives me the text I wanted ?
If you particularly only want the text, you can do something like this (but probably using a different stream as the destination for the text):
receiver = PDF::Reader::TextReceiver.new($stdout)
PDF::Reader.file("Arun.pdf", receiver)
Once you have the text, you could use regular expressions or whatever to get the specific value you want out of it.