Write error in prolog - prolog
My program(in SWI-Prolog) :
has_ram('one-v',512-mb-ram).
has_ram('one-s',1-gb-ram).
has_ram('m8',2-gb-ram).
has_ram('one-sv',1-gb-ram).
has_processor('one-v',1-ghz).
has_processor('one-s',1.5-ghz).
has_processor('one-m8',2.3-ghz).
has_processor('one-sv',1.2-ghz).
has_brand('one-v',htc).
has_brand('one-s',htc).
has_brand('m8',htc).
has_brand('one-sv',htc).
get_phone_details(X):-
has_brand(X,Y),
has_ram(X,Z),
has_processor(X,P),
write("Name :",X),nl,
write("Brand :",Y),nl,
write("Ram :",Z),nl,
write("Processor :",P).
ERROR Which i got :
ERROR: write/2: Domain error: `stream_or_alias' expected, found `[78,97,109,101,32,32,32,58]'
I would like to get the details of the phone as output.
write/1 doesn't work like that, you can write :
write('Name ':X),nl,
write('Brand ':Y),nl,
write('Ram ':Z),nl,
write('Processor ':P).
Related
Prolog syntax error: illegal start of term
So I'm trying to test my the predicate reduce/4 defined as following: :- op(20,xfy,?=). reduce(R,X ?=Y,P,Q) :- R=rename, regle(X ?=Y,R), length(P,N), trouve(Y,P,N,M), remove(N,M,P,Q). but i keep getting this error: ?- reduce(rename,X ?= Y,[?=(X,Y),?=(f(a),g(Z)),?=(X,a)],Q]. ERROR: Syntax error: Illegal start of term ERROR: reduce(rename,X ?= Y,[?=(X,Y),?=(f(a),g(Z)),?=(X,a)], ERROR: ** here ** ERROR: Q] . I'm new to Prolog so maybe it is something stupid.
You use ] instead of ) to close the bracket of reduce reduce(rename,X ?= Y,[?=(X,Y),?=(f(a),g(Z)),?=(X,a)],Q]. % ^open ^close You can fix this with: ?- reduce(rename,X ?= Y,[?=(X,Y),?=(f(a),g(Z)),?=(X,a)],Q). I cannot validate if this solves your problem, because you did not provide a definition for regle/2, etc. But the fact that I get a semantic error, seems to solve the syntax error nevertheless.
Get the node name for xpath in Robot Framework
Can't find the solution to my issue. I have nodes to be identified, I mean - I have to get nodes names for following case: <content-scope scope-data="scopeData"> <link-group data="scopeData[0]"> <text-img data="scopeData[1]"> </content-scope> When I'm using following syntax (FirePath, directly from browser) name((//content-scope[#scope-data='scopeData']/*)[1]) or name((//content-scope[#scope-data='scopeData']/*)[2]) then I get node name ( link-group and text-img). In robot-framework it doesn't work with keywords Get Text or Get Value. I get message: "InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression name((//content-scope[#scope-data='scopeData']/*)[1]) because of the following error: TypeError: Failed to execute 'evaluate' on 'Document': The result is not a node set, and therefore cannot be converted to the desired type. (Session info: chrome=44.0.2403.157)" Here is a RF code (little simplified): *** Settings *** Documentation Cards keywords library Library ExtendedSelenium2Library Library Collections *** Variables *** ${cardsXpathNameStart} xpath=name(//content-scope[#scope-data='scopeData']/*)[ ${index} 1 *** Test Cases *** Getting Card Xpath Type Get Card Xpath Type *** Keywords *** Get Card Xpath Type : FOR ${index} IN RANGE 1 2 \ ${cardXpathType} Get Text ${cardsXpathNameStart}${index}] \ Log ${cardXpathType} How to build correct xpath which is interpreted by RF or which keyword should be used?
I have the solution from WarBar (google groups, robotframework-users): RF code: Open Browser file:///D:/temp/rf/a.html ${elements} Get Webelements //content-scope[#scope-data='scopeData']/* log ${elements[0].tag_name} gives result: 20150826 10:37:37.551 : INFO : Creating an instance of the Firefox WebDriver 20150826 10:37:40.326 : INFO : Opening url 'file:///D:/temp/rf/a.html' 20150826 10:37:40.474 : INFO : ${elements} = [<selenium.webdriver.remote.webelement.WebElement object at 0x03FCBA10>] 20150826 10:37:40.485 : INFO : link-group
prolog get syntax error when increase stack size
Trying to solve the puzzle task with prolog and got some problems. 1002 Stack Overflow. Re-configure with Setup if necessary. So, I've tried to increase stack size in setup and run program again. But it causes the other error: Syntax error on line... The error line is line with operator "not" in predicate. Here is my code: domains age = integer childname,ffood,fear = string child = child(childname,age,ffood,fear) children = child* predicates solve name(child,childname) fear(child,fear) age(child,age) ffood(child,ffood) keys(children) solution(children) elder(child) member(children,child) structure(children) clauses member([X|_],X). member([_|SP],X):-member(SP,X). name(child(A,_,_,_),A). age(child(_,A,_,_),A). ffood(child(_,_,A,_),A). fear(child(_,_,_,A),A). structure([child("Dima",_,_,_),child("Kate",_,_,_),child("Misha",_,_,_),child("Sveta",_,_,_),child("Ura",_,_,_)]). elder(child(_,A,_,_)):-A=7;A=8. solve:-structure(Children),keys(Children),solution(Children). keys(Struct):- member(Struct,child(_,4,_,_)), member(Struct,child(_,5,_,_)), member(Struct,child(_,6,_,_), member(Struct,child(_,7,_,_), member(Struct,child(_,8,_,_)), member(Struct,child(_,_,"Banana",_), member(Struct,child(_,_,"Icecream",_), member(Struct,child(_,_,"Pizza",_), member(Struct,child(_,_,"Pasta",_), member(Struct,child(_,_,"Chocolate",_), member(Struct,child(_,_,_,"Thunderstorm"), member(Struct,child(_,_,_,"Spiders"), member(Struct,child(_,_,_,"Ghosts"), member(Struct,child(_,_,_,"Dogs"), member(Struct,child(_,_,_,"Darkness"), member(Struct,Child1), name(Child1,"Kate"), elder(Child1), not(fear(Child1,"Darkness")), not(ffood(Child1,"Chocolate")), member(Struct,Child2), name(Child2,"Sveta"), elder(Child2), not(fear(Child2,"Darkness")), not(ffood(Child2,"Chocolate")), ffood(Child2,"Pizza"), not(fear(Child2,"Spiders")), member(Struct,Child3), age(Child3,5), fear(Child3,"Ghosts"), member(Struct,Child4), age(Child4,6), fear(Child4,"Thunderstorm"), not(ffood(Child4,"Chocolate")), not(ffood(Child4,"Pasta")), member(Struct,Child5), age(Child5,4), ffood(Child5,"Banana"), member(Struct,Child6), age(Child6,8), not(fear(Child6,"Dogs")), member(Struct,Child7), name(Child7,"Dima"), not(age(Child7,5)), not(fear(Child7,"Darkness")), not(fear(Child7,"Spiders")), not(ffood(Child7,"Banana")), member(Struct,Child8), name(Child8,"Misha"), not(fear(Child8,"Darkness")), not(fear(Child8,"Spiders")), not(ffood(Child8,"Banana")). solution (Children):- write ("Solve:"), write (Children). goal solve. Found strange this prolog behavior... maybe somebody had the same problem?
I tried to reformat your code with SWI-Prolog: keys(Struct):- member(Struct,child(_,4,_,_)), member(Struct,child(_,5,_,_)), member(Struct,child(_,6,_,_), member(Struct,child(_,7,_,_), member(Struct,child(_,8,_,_)), member(Struct,child(_,_,"Banana",_), ... seems you're missing some parenthesis... after the obvious correction, I get ?- solve. Solve:[child(Dima,6,Icecream,Thunderstorm),child(Kate,8,Pasta,Spiders),child(Misha,5,Chocolate,Ghosts),child(Sveta,7,Pizza,Dogs),child(Ura,4,Banana,Darkness)] true .
Opa : give a name to a binary resource
I'm trying to download a file from an opa database. I've used the following code : case {path:[], query:[("download", filename)], ...} : Resource.binary(/myDatabase[filename], "application/txt") It's working fine, but the file I download is always named "download.txt". How can I change this name ? Thanks
case {path:[], query:[("download", filename)], ...} : Resource.binary(/myDatabase[filename], "application/txt") |> Resource.add_header(_, {content_disposition={attachment=filename}})
CUDAPP 1.1 cudppSort configuration error (Invalid configuration argument)
I am trying to call cudppSort to sort a set of keys/values. I'm using the following code to set up the sort algorithm: CUDPPConfiguration config; config.op = CUDPP_ADD; config.datatype = CUDPP_UINT; config.algorithm = CUDPP_SORT_RADIX; config.options = CUDPP_OPTION_KEY_VALUE_PAIRS | CUDPP_OPTION_FORWARD | CUDPP_OPTION_EXCLUSIVE; CUDPPHandle planHandle; CUDPPResult result = cudppPlan(&planHandle, config, number_points, 1, 0); if (CUDPP_SUCCESS != result) { printf("ERROR creating CUDPPPlan\n"); exit(-1); } The program exits, however on the line: CUDPPResult result = cudppPlan(&planHandle, config, number_points, 1, 0); and prints to stdout: Cuda error: allocScanStorage in file 'c:/the/path/to/release1.1/cudpp/src/app/scan_app.cu' in line 279 : invalid configuration argument. I looked at the line in scan_app.cu. It is, CUT_CHECK_ERROR("allocScanStorage"); So apparently my configuration has an error that is causing the allocScanStorage to bomb out. There are only two calls to CUDA_SAFE_CALL in the function and I don't see a reason why either has anything to do with the configuration. What is wrong with my configuration?
So that this doesn't sit around as an unanswered question (I'm not sure if this is the right SO etiquette but it seems like an answered question shouldn't sit around unanswered...), I'm copying the comment I made above here as an answer since it was the solution: I figured this out (I'm still learning CUDA at the moment.) Because the error checking is asynchronous errors can show up in strange places if you don't check for them from time to time. My code had caused an error before I called cudppPlan but because I didn't check for errors the cudppPlan reported the error as if it was in cudppPlan.