term

Convert complex term to List of lists and then back to term with modified functor

落花浮王杯 提交于 2021-02-11 12:28:50
问题 you can use =.. to convert simple terms. ?- x(a,b,c) =.. A. A = [x, a, b, c]. what about complex terms : x(a,b(c,d)) ==> [x,a,[b,c,d]] x(a,b(c,q(d))) ==> [x,a,[b,c,[q,d]]] then as separate task i want to re-generate the terms with changed functor : x(a,b(c,d)) ==> [x,a,[b,c,d]] ==> y(a,f(c,d)) 回答1: deep_univ(X, Y) :- X =.. [H|Rest], ( Rest = [] -> Y = X ; maplist(deep_univ, Rest, ExpRest), Y=[H|ExpRest] ). rev_univ([H|Rest], Y) :- maplist(rev_univ, Rest, RestT), Y =.. [H|RestT]. rev_univ(H, H

Convert complex term to List of lists and then back to term with modified functor

不羁岁月 提交于 2021-02-11 12:27:35
问题 you can use =.. to convert simple terms. ?- x(a,b,c) =.. A. A = [x, a, b, c]. what about complex terms : x(a,b(c,d)) ==> [x,a,[b,c,d]] x(a,b(c,q(d))) ==> [x,a,[b,c,[q,d]]] then as separate task i want to re-generate the terms with changed functor : x(a,b(c,d)) ==> [x,a,[b,c,d]] ==> y(a,f(c,d)) 回答1: deep_univ(X, Y) :- X =.. [H|Rest], ( Rest = [] -> Y = X ; maplist(deep_univ, Rest, ExpRest), Y=[H|ExpRest] ). rev_univ([H|Rest], Y) :- maplist(rev_univ, Rest, RestT), Y =.. [H|RestT]. rev_univ(H, H

ElasticSearch filter by nested boolean type fields

和自甴很熟 提交于 2021-01-29 14:22:51
问题 I need to query on multiple nested fields on boolean types. Structure of mapping: "mappings" : { "properties" : { "leaders" : { "type" : "nested", "properties" : { "except_1" : { "type" : "boolean" }, "except_2" : { "type" : "boolean" }, "counter" : { "type" : "integer" } } } } } I am trying to use query both except1 and except2 only to False . Below my try, unfortunately it returns True and False for both fields and I cannot fix it. "query": { "nested": { "path": "leaders", "query": { "bool"

Elasticsearch multi term filter

不羁岁月 提交于 2020-07-31 06:26:28
问题 I'm quite new to Elasticsearch, so here's my question. I wanna do a search query with elasticsearch and wanna filter with multiple terms. If I want to search for a user 'tom', then I would like to have all the matches where the user 'isActive = 1', 'isPrivate = 0' and 'isOwner = 1'. Here's my search query "query":{ "filtered": { "query": { "query_string": { "query":"*tom*", "default_operator": "OR", "fields": ["username"] } }, "filter": { "term": { "isActive": "1", "isPrivate": "0", "isOwner"

Converting list to terms in Prolog

浪子不回头ぞ 提交于 2020-01-16 09:13:39
问题 I have to implement the predicate cons(List, Term) that will take a list [Head|Tail] and convert it to terms, represented as next(Head, Tail) . How do I do this? I don't even know where to start. Here is the example of a successful query given in the question: cons([a,b,c],X). /*query returns X=next(a,next(b,next(c,null))).*/ 回答1: Doing most anything with lists will require that you consider two cases: the empty list and a list with a head and a sublist. Usually your base case is handling the

Installing Term::TermKey returns error

走远了吗. 提交于 2019-12-24 10:00:33
问题 I have a problem while installing Term::TermKey with CPAN and I can't find information about how to solve it. Here is an output: cpan[9]> install Term::TermKey Running install for module 'Term::TermKey' Running Build for P/PE/PEVANS/Term-TermKey-0.10.tar.gz Checksum was ok '/usr/bin/perl Build.PL installdirs=site' returned status 256, won't make Running Build test Make had some problems, won't test Running Build install Make had some problems, won't install May someone help me? //edit I

ACF front end form to update term

坚强是说给别人听的谎言 提交于 2019-12-24 05:54:56
问题 I want to use ACF frontend form function to create a form with custom fields I see this issue for create new term, @Alhana ACF front end form to create term but I want to generate the form with old data 回答1: Well, i didn't see that question, but if it's still actual, here's a solution. First of all, make sure you have ACF group, linked to your taxonomy. You will need ID of this group, it can be found in url on group edit page, for example: http://site.ru/wp-admin/post.php?post=340&action=edit