list

Shuffling a list in PROLOG

倾然丶 夕夏残阳落幕 提交于 2021-02-11 15:03:26
问题 Simple question, how can I shuffle a list in PROLOG, so that A1 is my new list? shuffle([1,1,1,2,3,4],A1), I've tried a few predicates I found on the web but none of them seems to be working. Also found this but apparently it's not available anymore, according to SWI-PROLOG. 回答1: You can use random_permutation/2 . It is available in SWI-Prolog. ?- random_permutation([1,2,3],L). L = [1, 3, 2]. 来源: https://stackoverflow.com/questions/27431281/shuffling-a-list-in-prolog

Accessing the name of a list by defining a new class, error: NamedList instance has no attribute '__len__'

守給你的承諾、 提交于 2021-02-11 14:44:12
问题 I am pretty new to python, So I have created a list of elements like: main_list = [1,2,3] I want this list to have a name and I don't want to use a dictionary, so I have created a class with the name as an attribute: class NamedList: def __init__(self, name, obj) self.name = name self.object = obj when I try to access the length of the first list: len(main_list) #works fine but for the second one it gives me this error: NamedList instance has no attribute ' len ' : new_main_list = NamedList(

Remotely get serial number and model from list in batch script

二次信任 提交于 2021-02-11 14:25:13
问题 I am trying to create a simple script that will use computer name from pclist.txt and get serial number and model and export to csv file. I just can not seem to figure out why it does not print the serial number and model in the csv file. Here is my simple script. @echo off for /f %%i in (pclist.txt) do ( for /f "tokens=2 delims==" %%M in ('wmic /node:%%i csproduct get name /value') do set "Model=%%M" for /f "tokens=2 delims==" %%I in ('wmic /node:%%i bios get serialnumber /value') do set "SN

How to add a clickable button in a List without triggering NavigationLink event?

心不动则不痛 提交于 2021-02-11 13:46:41
问题 I have a button in a list item and when I click on it, the NavigationLink's event is also being triggered. I only want to trigger the button event. How to do it? following is my code: ForEach(self.cares,id:\.id){ care in HStack{ if(care.markMode == "打卡"){ Button("今日未打卡"){ } else{ Button("新增记录"){ self.care = care self.showSheetNewMark.toggle() } } NavigationLink(destination:CareDetailView(care: care)){ Text("\(care.nickname!)的\(care.subject!)") } } } 回答1: Add PlainButtonStyle for button, as in

How to add a clickable button in a List without triggering NavigationLink event?

泄露秘密 提交于 2021-02-11 13:44:29
问题 I have a button in a list item and when I click on it, the NavigationLink's event is also being triggered. I only want to trigger the button event. How to do it? following is my code: ForEach(self.cares,id:\.id){ care in HStack{ if(care.markMode == "打卡"){ Button("今日未打卡"){ } else{ Button("新增记录"){ self.care = care self.showSheetNewMark.toggle() } } NavigationLink(destination:CareDetailView(care: care)){ Text("\(care.nickname!)的\(care.subject!)") } } } 回答1: Add PlainButtonStyle for button, as in

How do I merge two seperate '.ToList()"?

こ雲淡風輕ζ 提交于 2021-02-11 13:40:59
问题 There are several posts where people are asking how to merge generic lists. However, in my case I have two seperate linq statements where I am returning two separate database results .ToList() var appleList = (from al in db.Apples where al.Id == id select al).ToList(); var bananaList = (from bl in db.Bananas where bl.Id == id select bl).ToList(); I tried merging these list like so: appleList.Concat(bananaList); but this causes the following error: 'List' does not contain a definition for

Finding consecutive text elements in list that match pattern

社会主义新天地 提交于 2021-02-11 13:30:03
问题 I am dealing with lists ls that look like the following: ls = ['y4','j8','Le1','Retx3','MNxe4','Xe4','Xf4','Xe5'] Given one such list, I am trying to find out if it contains 3 consecutive elements that match the following pattern: 3 consecutive elements starting with the letter X , and having the same length (here 3). And their ending digits may only correspond to either of the following cases: denote the ending digit of the first found element by n , then the allowed sequences of the 3

Finding consecutive text elements in list that match pattern

回眸只為那壹抹淺笑 提交于 2021-02-11 13:29:05
问题 I am dealing with lists ls that look like the following: ls = ['y4','j8','Le1','Retx3','MNxe4','Xe4','Xf4','Xe5'] Given one such list, I am trying to find out if it contains 3 consecutive elements that match the following pattern: 3 consecutive elements starting with the letter X , and having the same length (here 3). And their ending digits may only correspond to either of the following cases: denote the ending digit of the first found element by n , then the allowed sequences of the 3

Merge different lists together in Python

安稳与你 提交于 2021-02-11 12:58:56
问题 I am so called newbie in Python. I have difficulties with lists. I have a loop which take some info from textfile and goes through function. If textfiles lenght is 10 rows then output will be 10 separate lists, like that: [0.45] [0.87] ... and so on, for n+1 times(it depends how long textfile is). How can I put them into single list, like [0.45, 0.87, ...]? I experimented with different loops but nothing :( I am previously thankfull :) .. and sry about my bad english Code: from pyfann import

Merge different lists together in Python

自闭症网瘾萝莉.ら 提交于 2021-02-11 12:58:06
问题 I am so called newbie in Python. I have difficulties with lists. I have a loop which take some info from textfile and goes through function. If textfiles lenght is 10 rows then output will be 10 separate lists, like that: [0.45] [0.87] ... and so on, for n+1 times(it depends how long textfile is). How can I put them into single list, like [0.45, 0.87, ...]? I experimented with different loops but nothing :( I am previously thankfull :) .. and sry about my bad english Code: from pyfann import