i'm a new on Prolog, and i'm already having some problems to understand, the thing
is, i was making a test on appending some strings introduced by console:
append_str([],Adder,Adder).
append_str([Head|Tail],Adder,Result):-
append_str(Tail,[Head|Adder],Result).
sread_str(String):-
read(String),
atom(String).
sinput:-
sinput_str([]).
sinput_str(Lista):-
sread_str(String),
sinput_str([String|List]).
sinput_str(List):-
append_str(List,[],Result),
nl,
display(Result),
nl.
And eventually always getting this output:
|-? sinput.
sinput.
hello.
hello.
world.
world.
9.
9.
'.'(hello,'.'(world,[]))
The number is just for the console to end asking for some more values, i don't know what is wrong, thank you guys in advance.
you should try to understand what happens when you enter a number, forcing sread_str to fail.
Prolog explores all the alternatives available to prove a given goal, and doing so change the variables, undoing such changes when a path fail. Such model it's complicated by side effects required by IO (the read/display builtins).
Then attempt first to have a working sinput_str, something like this
sinput_str([String|List]):-
sread_str(String),
sinput_str(List).
sinput_str([]).
Related
I have a list of variables {a,b,c,d} (the lists I have are much bigger, this is a small example). I want to make the following list: {a->1, b->1, c->1, d->1}. I tried {a,b,c,d}->1, but this does not work and I dont know how to search for the right keywords.
That is pretty easy in Mathematica:
Thread[{a, b, c} -> 1]
Now, that you know this one function Thread, go into the documentation center and read through the material. Then you can look at the very bottom of the doc-page and you find plenty of guides and related functions that give you hints on where to go from there.
I am wondering to know why pre-trained 'fasttext model' with wiki(Korean) seems not to work well! :(
model = fasttext.load_model("./fasttext/wiki.ko.bin")
model.cosine_similarity("테스트 테스트 이건 테스트 문장", "지금 아무 관계 없는 글 정말로 정말로")
(in english)
model.cosine_similarity("test test this is test sentence", "now not all relative docs really really ")
0.99....??
Those sentence is not at all relative as meaning. Therefore I think that cosine-similarity must be lower. However It was 0.997383...
Is it impossive to compare lone sentents with fasttext?
So Is it only way to use doc2vec?
Which 'fasttext' code package are you using?
Are you sure its cosine_similarity() is designed to take such raw strings, and automatically tokenize/combine the words of each example to give sentence-level similarities? (Is that capability implied by its documentation or illustrative examples? Or perhaps does it expected pre-tokenized lists of words?)
How to make auto-completion list all (static) fields of a certain class that has appropriate variable-type when ctrl+space at a slot of parameter in a certain function?
Example
I tried to ctrl+space in the below code :-
(Code as text is here.)
Question: How to make it show E_1 E_2 E_3?
I don't mind another plugin if I really need one.
It currently works but only for enum :-
My workaround
In practice, to get smart clue, I have to type more (PrototypeList::) :-
Bounty Reason
Here is the result of the current answer (citizenmatt's):-
It is different, but still not show E_1 E_2 E_3.
Have you tried Smart Completion? This feature will only show completion items that are valid for the current context. I think it works in C++, too.
In fact, ReSharper does help you here. All of E_1, E_2 and E_3 are in the completion list, but not on the top of it - they are assigned lower scores because they need an additional qualifier. That said, looks like there is still an issue with scoring:
E_2 and E_3 are in the list too, but they are not shown alongside E_1. We'll investigate this (RSCPP-19501).
I'm doing problems at 4Clojure. Some how, when I finished a problem (around #22), a link appeared that jumped me to problem #35. I want to do the problems that were skipped. But when I'm logged in to 4Clojure, the website only shows me problems after the last one I completed, which is #34.
Is there way to see all the problems (completed and uncompleted) at 4Clojure, so I can do the skipped ones?
The headers on the problem list page are all clickable to change sort order. The default sort order is something like "sort first on whether you've solved it, and then on how many other people have solved it", so problems you've solved drift to the bottom (which is on page 2). You can click a heading to sort differently: for example, click on the Solved heading to see the problems you've already solved first.
Or, of course, you can just edit the URL, since the URLs are very predictable: http://www.4clojure.com/problem/22 will be problem #22.
Change the number in the URL:
http://www.4clojure.com/problem/[problem]
Your completed problems appear at the very end of the problem list.
There seems to be a list of all the problems:
Problem List
However they are not numbered.
I'm sorry, I'm showing too many lines of code but I just have a small problem.
Take a look at the code file, you'll see two areas which I marked via comment [1] and [2] (Maybe you'll need [3]).
When I run the program, because this is a console program so the screen will have something like:
Befor callback: 0
After callback: 0
It should be After callback: 99 that is what I need.
My question is Why doesn't iResult variable change after I modify it?
Update 1
The 1st agrument of callback function points to where (this) pointer (in [3])points to.
Thank you guys.
When you call run_query to execute your query, it assigned the result of the sqlite3_exec call to iResult. This overwrites the 99 with the result of the query, which is 0.
It's just about everything not optimal about this code. If you're doing something simple, sonsider using an available wrapper, such as hiberlite. There are more low level ones as well.
Try to read about clean code first and about SOLID principles and then about patterns in enterprise software
This is also not what "modern" C++ is good for. Do you really want to do it in C++?
Then, you're doing something dangerous as well - you're assembling a query from a string by not using value binding.