Posts

Showing posts from June, 2014

java - update oracle DB data from CSV file using Hibernate -

need update oracle db table data csv using hibernate. there prepared statement batch update equivalent in hibernate or there optimal hibernate approach in updating db data csv? hibernate 1 of orm tools. object-relational mapping (orm, o/rm, , o/r mapping tool) in computer science programming technique converting data between incompatible type systems in object-oriented programming languages. creates, in effect, "virtual object database" can used within programming language. it means using orm have to: deserialize data csv map objects then serialize objects , store relational db . don't find redundantly? is there optimal hibernate approach in updating db data csv? the answer not. there no optimal hibernate approach because it's redundant meaningless work use orm. in case plane dao layer more effective , suitable.

oracle11g - SQL: LIKE with OR vs IN -

is there performance difference between following? name '%expression_1%' or name '%expression_2%' ... or name '%expression_n%' vs name in (actual_value_1,actual_value_2,.., actual_value_n) the in version potentially much, faster. the 2 versions not same thing. but, if either meets needs, in version can take advantage of index on name . like version cannot, because pattern starts wildcard. you write as: where name 'expression_%' if meets needs, can take advantage of index on name .

ios - UICollectionView reuse cell issue -

i have problem collection view cell. when collection view first loaded, display items that: - (uicollectionviewcell *)collectionview:(uicollectionview *)cv cellforitematindexpath:(nsindexpath *)indexpath; { calendarcell *cell = [cv dequeuereusablecellwithreuseidentifier:@"calendarcell" forindexpath:indexpath]; [cell binddate:_datesmgr.currentmonthitems[indexpath.row] andnowdate:_datesmgr.nowdate]; // bind events if (_eventsmgr.eventsarray.count > 0){ (int = 0; < _eventsmgr.eventsarray.count ; ++) { [cell bindconference:_eventsmgr.eventsarray[i]]; } } return cell; } inside methods logic adding subviews custom cell class, depend on circumstances. its work, but, when collection view reloaded (i did force reload after 1 second) of cells reused , placed on others, therefore, show "old" images , subviews. i see possible solution in forcing uicollection view stop reusing cells (it is, load new c

matplotlib - Why does the Seaborn color palette not work for Pandas bar plots? -

Image
an online jupyter notebook demonstrating code , showing color differences at: https://anaconda.org/walter/pandas_seaborn_color/notebook the colors wrong when make bar plots using pandas dataframe method. seaborn improves color palette of matplotlib. plots matplotlib automatically use new seaborn palette. however, bar plots pandas dataframes revert non-seaborn colors. behavior not consistent, because line plots pandas dataframes do use seaborn colors. makes plots appear in different styles, if use pandas plots. how can plot using pandas methods while getting consistent seaborn color palette? i'm running in python 2.7.11 using conda environment necessary packages code (pandas, matplotlib , seaborn). import pandas pd import matplotlib.pyplot plt import seaborn sns df = pd.dataframe({'y':[5,7,3,8]}) # matplotlib figure correctly uses seaborn color palette plt.figure() plt.bar(df.index, df['y']) plt.show() # pandas bar plot reverts default matplotlib

PHP: Filtering and export large amount of data from MySQL database -

i have large database table (more 700k records) need export .csv file. before exporting it, need check options (provided user via gui) , filter records. unfortunately filtering action cannot achieved via sql code (for example, column contains serialized data, need unserialize , check if record "passes" filtering rules. doing records @ once leads memory limit issues, decided break process in chunks of 50k records. instead of loading 700k records @ once, i'm loading 50k records, apply filters, save .csv file, load other 50k records , go on (until reaches 700k records). in way i'm avoiding memory issue, takes around 3 minutes (this time increase if number of records increase). is there other way of doing process (better in terms of time) without changing database structure? thanks in advance! the best thing 1 can php out of mix as possible. case loading csv, or exporting it. in below, have 26 million row student table. export 200k rows of it. granted

excel cell locations based on value in another cell -

i using excel 2010. able use value of cell (such value in cell a1) in function define location data spreadsheet. ='sheet1'!$b$xx (where value of xx defined in cell a1) you can use index, preferable use index less volatile. =index(b:b,a1) this returns value or reference value within table or range

javascript - Highlight area as one searches for - By give it a red background -

it such i'm trying right jquery find determining search words, example searching for. let find "lorem" highlight text red shift. i have on: add() find() html site: <div id="searchbox"> <div class="col-md-6"> <h2>hello world</h2> <p>lorem ipsum er ganske enkelt fyldtekst fra print- og typografiindustrien. lorem ipsum har været standard fyldtekst siden 1500-tallet, hvor en ukendt trykker sammensatte en tilfældig spalte @ trykke en bog til sammenligning af forskellige skrifttyper. lorem ipsum har ikke alene overlevet fem århundreder, men har også vundet indpas elektronisk typografi uden væsentlige ændringer. sætningen blev gjordt kendt 1960'erne med lanceringen af letraset-ark, som indeholdt afsnit med lorem ipsum, og senere med layoutprogrammer som aldus pagemaker, som også indeholdt en udgave af lorem ipsum.</p> </div> <div class="col-md-6"> <h2>hello world<

c++ - ROS rosmake error -

i working on project ros. new ros , it's features. i'm doing tutorial on ros , started using code first time. although have experience c++, can't figure out going wrong. in ros use rosmake command , fails compile cpp file/code. can me figure out why error occurs? (and possibly how fix it?) below cpp file code: #include "ros/ros.h" #include "std_msgs/string.h" #include <sstream> int main(int argc, char **argv) { ros::init(argc, argv, "example1_a"); ros::nodehandle n; ros::publisher chatter_pub = n.advertise<std_ msgs::string>("message", 1000); ros::rate loop_rate(10); while (ros::ok()) { std_msgs::string msg; std::stringstream ss; ss << " example1_a node "; msg.data = ss.str(); //ros_info("%s", msg.data.c_str()); chatter_pub.publish(msg); ros::spinonce(); loop_rate.sleep(); } return 0; } and here build log: mkdir -p bin cd build && cmake -wdev -dcmake_toolchain_file=/opt/ros/in

arrays - I need help compressing this IF statment down as much as possible in C++ -

i have several if statements compress as possible each time in array number 1 appears add 1 ones int. if (dice[1] == 1) { ones ++; } if (dice[2] == 1) { ones ++; } if (dice[3] == 1) { ones ++; } if (dice[4] == 1) { ones ++; } if (dice[5] == 1) { ones ++; } you're counting 1 values in sequence , there's standard library algorithm that. takes 2 iterators , i'm giving pointers in case. ones += std::count(&dice[1], &dice[6], 1); this same thing , people might prefer form. ones += std::count(dice + 1, dice + 6, 1);

scripting - Exporting a bunch of Google Calendar .ics files, to a folder on Google Drive -

i have several calendars in google account, set periodical back-up. each calendar has specific export url .ics file, e.g. https://calendar.google.com/calendar/exporticalzip?cexp=insert_long_string_of_characters i'd take each export link each calendar, , have sort of script export files designated folder on google drive (instead of local machine) is such thing possible? thanks! jamie to specific export url, can use method 'files:get' file's metadata id. under downloadurl has exportlinks including (key). retrieve appropriate download url provided in file's metadata retrieve actual file content or link using download url. to download files, make authorized http get request file's resource url , include query parameter alt=media get https://www.googleapis.com/drive/v2/files/0b9jnhsvvjoivm3dkcgrkrmviovu?alt=media authorization: bearer ya29.ahesvbxtuv5mhmo3ryfms1yjonjzzdtofzwvyoauvhrs private static inputstream downloadfile(drive servic

python - How to capture and use data after commands in argparse? -

hello understand nothing in argparse documentation. want able capture , use data given user follow given command. for instance : python func.py -type mult -data 2 3 1 6 (2*3*1) python func.py -type add -data 2 5 1 8 (2+5+1) how function ? import argparse parser = argparse.argumentparser( description="math equations", formatter_class=argparse.rawtexthelpformatter ) parser.add_argument("-type", choices=("mult", "add", "div", "sub"), required=true) parser.add_argument("-data", nargs='+', type=int, required=true) # '+' nargs means 1 or more. if want limited three, change 3. args = vars(parser.parse_args()) print(args) for python func.py -type mult -data 2 3 1 : {'data': [2, 3, 1], 'type': 'mult'} for python func.py -type mul -data 2 3 1 : usage: func.py [-h] -type {mult,add,div,sub} -data data [data ...] test.py: error: argument -type: invali

sql server - UNION versus SELECT DISTINCT and UNION ALL Performance -

Image
is there difference between these 2 performance-wise? -- eliminate duplicates using union select col1,col2,col3 table1 union select col1,col2,col3 table2 union select col1,col2,col3 table3 union select col1,col2,col3 table4 union select col1,col2,col3 table5 union select col1,col2,col3 table6 union select col1,col2,col3 table7 union select col1,col2,col3 table8 -- eliminate duplicates using distinct select distinct * ( select col1,col2,col3 table1 union select col1,col2,col3 table2 union select col1,col2,col3 table3 union select col1,col2,col3 table4 union select col1,col2,col3 table5 union select col1,col2,col3 table6 union select col1,col2,col3 table7 union select col1,col2,col3 table8 ) x the difference between union , union all union all not eliminate duplicate rows, instead pulls rows tables fitting query specifics , combines them table. a union stateme

Incorporating time series into a mixed effects model in R (using lme4) -

i've had search similar questions , come short apologies if there related questions i've missed. i'm looking @ amount of time spent on feeders (dependent variable) across various conditions each subject visiting feeders 30 times. subjects exposed feeders of 1 type have different combination of being scented/unscented, having visual patterns/being blank, , having these visual or scented patterns presented in 1 of 2 spatial arrangements. so far model is: mod<-lmer(timeonfeeder ~ scent_yes_no + visual_yes_no + pattern_one_or_two + (1|subject), data=data) how can incorporate visit numbers model see if these factors have effect on time spent on feeders on time? you have variety of choices (this question might marginally better crossvalidated ). as @dominix suggests, can allow linear increase or decrease in time on feeder on time. makes sense allow change vary across birds: timeonfeeder ~ time + ... + (time|subject) you could allow arbitrary

html - Append data within a class using pure Javascript -

i want append text within class using javascript, not using jquery. example: <div class="a"> <div class ="b"> <div class="c"> </div> </div> <div> after putting text within class="b" , should like: <div class="a"> <div class ="b"> text <div class="c"> </div> </div> <div> i want without using jquery. using insertadjacenthtml() method: var elements = document.getelementsbyclassname("b"); // elements class 'b' (var = 0; < elements.length; i++) { // every element class 'b': elements[i].insertadjacenthtml("afterbegin", "this text"); // insert text inside element } <div class="a"> <div class="b"><!-- text inserted here --> <div class="c">

jquery - Apache PHP looping, will it block other accesses to the server? -

i'm using phalcon framework build server, , i'm trying implement loop in function. for example, user gives input page, page uses ajax post input url of server, url on server doing looping work lasts 3 seconds. besides, page use ajax send url of server, in order progress of looping. stored progress in session. however, seems when server doing looping, can't respond other requests. observed, can see 2nd ajax sent multiple times, log got indicates function 2nd url called once. is limitation of phalcon? php? apache? or doing wrong configuration? some demo code shown here: javascript function query(point) { $.ajax( { url: "/work", type: 'post', datatype: 'json', data: {...}, success: function(data, status) { alert(data); if(progressinterval) { clearinterval(progressinterval); alert("finished");

android - Image Crop Not Working in Fragment -

below code working nic when using activity when implemet code in fragment after select image gallery or capture camera not showing crop option. image not showing in imageview. below camera handler: public class camerahandler { public static int image_pic_code = 1000, crop_camera_request = 1001, crop_gallary_request = 1002; private intent imagecaptureintent; private boolean isactivityavailable; context context; private list<resolveinfo> cameralist; list<intent> cameraintents; uri outputfileuri; intent galleryintent; uri selectedimageuri; private string cameraimagefilepath, absolutecameraimagepath; bitmap bitmap; imageview ivpicture; string ivpicture1 = string.valueof(ivpicture); public camerahandler(context context) { this.context = context; setfileuriforcameraimage(); } public void setivpicture(imageview ivpicture) { this.ivpicture = ivpicture; } private v

java - Custom Key Generation in Spring Caching -

i have started working on spring caching. this class in have implemented caching: @cacheconfig(cachenames="empcache") public class general { @cacheable public string getdetails(int empid) { if(empid==1) { system.out.println("inside getdetails. emp id 1."); return "amar"; } else { system.out.println("emp id not 1."); return "anthony"; } } } this custom bean user key generation: @component public class temp { private string name; private string surname; public string getname() { return name; } public void setname(string name) { this.name = name; } public string getsurname() { return surname; } public void setsurname(string surname) { this.surname = surname; } } my context.xml <context:component-scan base-package="com.packages.beans" /> <ca

node.js - Proper way to make callbacks async by wrapping them using `co`? -

it 2016, node has had full es6 support since v4, , promises have been around since 0.12. it's time leave callbacks in dust imo. i'm working on commander.js -based cli util leverages lot of async operations - http requests , user input. want wrap commander action s in async functions can treated promises, , support generators (useful co-prompt library i'm using user input). i've tried wrapping cb co in 2 ways: 1) program.command('mycmd') .action(program => co(function* (program) {...}) .catch(err => console.log(err.stack)) ); and 2) program.command('mycmd').action(co.wrap(function* (program) { .. })); the problem 1) program parameter isn't passed the problem 2) errors swallowed... i'd working yields nicer code in use case - involving lot of http requests , waiting user input using co-prompt library.. is better option altogether perhaps wrap program.command.prototype.action somehow? thanks!

excel - Running VBA code in alternate sheet triggers wrong results - despite referencing? -

the below code seeks pull value cell in the 'input' sheet, , display in 'output' sheet. shows difference between last value recorded , expresses figure percentage. when run code output sheet active works. however, when run output sheet doesn't. instead, displays value wish copy in column f in input sheet , displays difference , percentage difference in wrong cells in output sheet. it looks correctly referenced me, isn't. thoughts on how correct? i appreciate code tidier - i'm new this. sub button1_click() dim lastrow long dim recentrow long sheets("output") lastrow = .cells(.rows.count, "f").end(xlup).row recentrow = .cells(.rows.count, "f").end(xlup).offset(1, 0).row range("f" & lastrow).select activecell.offset(1, 0).formula = "=input!b4" activecell.offset(1, 0).copy activecell.offset(1, 0).pastespecial (xlvalues) end

c# - Specifying a DataType for a propertyinside a nested class? -

i'm making mvc5 website, , created viewmodel able access multiple models/classes in view. viewmodel contains classes generated entityframework. looks this: public class personeelskaartvm { public personeel personeel { get; set; } public gebruikers gebruikers { get; set; } public list<sysgroep> lidvansysgroep { get; set; } public list<relsgrps> lidvanrelsgrps { get; set; } public personeel_uren urenperjaar { get; set; } public persoon_overw overwerkperjaar { get; set; } public cboalgemeen status { get; set; } public list<relafdeling> lidvanrelafdeling { get; set; } public list<persoon_vakgroep> lidvanpersoonvakgroep { get; set; } public list<vakgroep> lidvanvakgroep { get; set; } public list<competentieentiteit> lidvanpersooncompetentie { get; set; } public list<competenties> lidvancompetenties { get; set; } //volle lijsten: public list<cboalgemeen> alleburgstaten { get; s

.net - Deserializing sequence of nested elements -

i'm stumped on how deserialize following xml entities i've created: <values totalcount="576"> <version>3</version> <item> <datetime>2/22/2016 8:35:00 pm - 8:40:00 pm</datetime> <value channel="outside" channelid="4">10.0000</value> </item> <item> <datetime>2/22/2016 8:40:00 pm - 8:45:00 pm</datetime> <value channel="inside" channelid="2"/> </item> </values> these classes i've used. when deserialize, valueitems list created correct number of items , correct totalcount , version values but each valueitem has default values members instead of expected values: public class values { [xmlattribute(attributename = "totalcount")] public int totalcount { get; set; } [xmlelement(elementname = "version")] public

java - Comparable interface project -

i'm stuck on project, far have got: public class myint implements comparable<myint> { private int value; myint(int x) { value = x; } public string tostring() { return ("" + value); } public int intvalue() { return value; } public int compareto(myint rhs) { myint myint = (myint) rhs; int myinteger = myint.intvalue(); int result = 0; if (value < myinteger) { result = -1; } else if (value == myinteger) { result = 0; } else { result = +1; } return result; } } and question: consider following java library interface: public interface comparable<t> { int compareto(t rhs); } complete implementation of class below implements above interface (note interface automatically imported java – not re-type in project). compareto method should return -1 if value less rhs.value, 0 if both sides equal ,

javascript - Amazon S3 file upload: POST 405 Method Not Allowed using ember-uploader -

i'm using ember-uploader upload file amazon s3. component simple: import ember 'ember'; import emberuploader 'ember-uploader'; export default emberuploader.filefield.extend({ signingurl: '/sign', filesdidchange (files) { const uploader = emberuploader.s3uploader.create({ signingurl: this.get('signingurl'), }); uploader.on('didupload', response => { console.log('upload successful!'); }); if (!ember.isempty(files)) { uploader.upload(files[0]); } } }); i've written simple node express script generates pre-signed url: var aws = require('aws-sdk'); var config = new aws.config({ accesskeyid: 'access-key-id', secretaccesskey: 'secret-access-key', region: 'us-east-1', }); aws.config = config; var bucketname = 'bucket-name'; var express = require('express'); var app = express(); app.use(fileupload()); app.use(function(

python - JSON.LOADS is picking only 2 resultset -

i trying use json search through googlemapapi. so, give location "plymouth" - in googlemapapi showing 6 resultset when try parse in json, getting length of 2. tried multiple cities too, getting resultset of 2 rather. wrong below? import urllib.request ur import urllib.parse urp import json url = "http://maps.googleapis.com/maps/api/geocode/json?address=plymouth&sensor=false" uh = ur.urlopen(url) data = uh.read() count = 0 js1 = json.loads(data.decode('utf-8') ) print ("length: ", len(js1)) result in js1: location = js1["results"][count]["formatted_address"] lat = js1["results"][count]["geometry"]["location"]["lat"] lng = js1["results"][count]["geometry"]["location"]["lng"] count = count + 1 print ('lat',lat,'lng',lng) print (location) simply replace for result in js1: for result in js1[&#

java - SonarQube giving unused private method issue for lambda usage -

i have following logic; .. if(list.stream() .filter(myclass::isenabled) .filter(this::isactive) .count() > 0) { //do smth } .. private boolean isactive(myclass obj) { return bool; } as see, isactive method being used in stream structure, when build class on jenkins, unused private method issue sonarqube, says should delete redundant private method. bug? if not, why haven't still included lambda logic in analyze structure? only solution is, obviously, this; .filter(obj -> isactive(obj)) , destroys uniformity, , readability (imo). this known issue of sonarqube java analyzer : https://jira.sonarsource.com/browse/sonarjava-583 this due lack of semantic analysis resolve method reference (thus identify method this::isactive refers to).

java - JSONArray cannot be converted to JSONObject exception -

i have json string structured in following way , throws exception passing jsonarray timejsonarray = new jsonarray(time); this error value [{"daysbyte":158,"from":1020,"to":1260},{"daysbyte":96,"from":1020,"to":1320}] @ 0 of type org.json.jsonarray cannot converted jsonobject how receive array , can't change it, i'm having trouble converting json object instead of json string format it's in. doing wrong? [ [ { "daysbyte":30, "from":660, "to":1290 }, { "daysbyte":96, "from":660, "to":1320 }, { "daysbyte":128, "from":1050, "to":1290 } ], [ { "daysbyte":252, "from":690, "to":840 }, { "daysbyte

javascript - angularjs save html from textarea -

Image
this html: <div ng-if="!item.edit> <div class='door-description' ng-bind-html="item.description"></div> <div class='door-softvalues' ng-bind-html="item.softvalues" ng-if="item.isconfiguration"></div> </div> <div ng-if="item.edit"> <textarea elastic class='door-description' ng-bind-html="item.description" ng-model="item.description"></textarea> <textarea elastic class='door-softvalues' ng-bind-html="item.softvalues" ng-if="item.isconfiguration" ng-model="item.softvalues"></textarea> </div> so linebreak looks when im in edit mode , edit textarea when save text , retrieve again looses linebreaks. here looks when editing: and here looks when not editing: i can still toggle between edit , not editing , same result. what have make l

centos - Magento 2.0.2 - File permissions for new files -

i using centos 6.7 , i'm trying magento installed on server. software correct versions magento run. during set-up, have followed magento's instructions here: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache-user.html the web host user , group "nobody", used in place of "apache". however, when tried these: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html the user created magento not permitted run commands. i attempted installation anyway, works, new files created magento not have correct permissions. running magento cleanup tool, fixes permissions new files, extremely slow process , magento creating new files. is there missed, or there else causing these issues?

java - drag and drop (checkmark if I drag the right image) android -

if drag countrytypical image , drop in imagecountry[n9] application set checkmark image on right countrytypical image. happens if drag right countrytypical image , if drag mistaken countrytypical image. correct error. many thanks... string[] countrynames = { "italy", "france", "spain", "germany", "belgium", "portugal", "switzerland", "great britain" }; int[] countryimages = { r.drawable.italy, r.drawable.france, r.drawable.spain,... }; int[] countryflags = { r.drawable.italian_flag, r.drawable.french_flag, r.drawable.spanish_flag,.... }; in oncreate: countrytypical1.setimageresource(countryflags[n1]); countrytypical2.setimageresource(countryflags[n2]); countrytypical3.setimageresource(countryflags[n3]); countrytypical4.setimageresource(countryflags[n4]); countrytypical5.setimageresource(countryflags[n5]); countrytypical6

c# - SQLDataReader returns string with additional break characters \\\\ -

i using sqldatareader in c# query sql table. 1 of fields in table string holds file path, example "c:\\files\\myfiles" . however, sqldatareade r returns string 2 additional backslashes. example: "c:\\\\files\\\\myfiles" . sqldatareader appears detecting escape character "\". there anyway can stop doing this? it somehow misleading developers when inspecting value in visual studio. string this: c:\\\\files\\\\myfiles but when print console exact string: console.writeline(path); /* c:\\files\\myfiles */ you can click magnifier icon check exact string characters. no worries, you're safe go it visual studio adding escape characters.

c# - Unity3D-2D: Setting Time.timeScale to 0 for a certain public prefab until positioned? -

so have button in game spawns "tower" @ given location. tower, when spawned, acts , can drag around using drag script. i wonder how can set time.timescale 0 when first spawn tower ( only prefab) untill click again set it's position. also after click on button want enable dragging script, set position , after click mouse disable dragging script. way can make sure players don't reposition towers damage. using unityengine; using system.collections; public class spawntower : monobehaviour { public gameobject frozenobject; public transform prefab; public void onclickspawn() { (int = 0; < 1; i++) { instantiate(prefab, new vector3(i * 2.0f, 0, 0), quaternion.identity); } } //this part here on not work! says getcomponent<>() method not valin in given context public void onclick() { if (input.getmousebuttonup(0)) { getcomponent<dragenemy>.enabled = false

java - How to run a Intellij IDEA created Maven project with Jenkins? -

i have created maven (java) project in intellij idea on macos. has standard directory structure, this: myproject | -- src -- main -- java -- java code goes here | | | ----- test -- java -- junit test code goes here | -- pom.xml -- myproject.xml my project generate jar file. in idea, have been able run maven build generate jar file run junit test. now, want use jenkins ci test project. have setup jenkins on linux box. jenkins can pull entire project structures linux box. my question is, on linux, given directory structure created intellij idea, how can run maven packet jar file , run junit test? that directory not specific idea, infact standard maven structure. if go project configurations of jenkins maven project see section can declare pom.xml , goals want run.

javascript - jquery/2.2.0 - TypeError: $.initElementData is not a function -

Image
i'm running a/b test , have written jquery works in preview panel - when push live - don't see changes , i'm seeing error: typeerror: $.initelementdata not function ...his,c);return}}c.unshift("generic events");this.generichandler.apply(this,c)}}) jquery.... > eval (line 1, col 9180) typeerror: $.ui undefined $.extend($.ui.autocomplete.prototype, { i've tried googling - , appears speak old version of jquery - i'm using latest? <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> please see code below: </head> <script> jquery.fn.extend({ live: function (event, callback) { if (this.selector) { jquery(document).on(event, this.selector, callback); } } }); //online //available online not available in stores $('div.result-sold').each(function() { if($(this).find('li:contains(&quo

racket - scheme - Show all the pairs of elements which have the greatest common divisor 1 -

i started algortihm combinations when m become 0 in recursion, first y '(()) program show () repeat 4*the size of list times. (define (pairs-gcd l) (define (comb m lst) (cond ((= m 0) '(())) ((null? lst) '()) (else (append (map (lambda (y) (cond (equal? (gcd(car lst) y) 1) (cons (car lst) y))) (comb (- m 1) (cdr lst))) (comb m (cdr lst)))))) (comb 2 l) ) edit: corrected output input: '(2 5 3 6 11 15) output: '((2 5) (2 3) (2 11) (2 15) (5 3) (5 6) (5 11) (6 11) (3 11) (6 11) (11 15)) this simple if use racket's built-in procedures - can generate 2-element combinations, test them given condition , output list correct pairs: (define (pairs-gcd lst) (for/list ([pair (in-combinations lst 2)] #:when (= (apply gcd pair) 1)) pair)) for example: (pairs-gcd '(2 5 3 6 11 15)) => '((2 5) (2 3) (5 3) (5 6) (2 11) (5 11) (3 11) (6 11) (2 15) (11 15))

vhdl - variable must be constrained error -

i getting error , don't understand why. my code : library ieee; use ieee.std_logic_1164.all; use work.func_pack.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; --use ieee.numeric_std.all; entity letters_arranger port ( clock, reset,start,rdy_to_get_new_letter :in std_logic; -- asuuming clock 27 m hz select_input : in integer; reg : out std_logic_vector(7 downto 0); drive_letter : out std_logic ); end letters_arranger ; architecture behave of letters_arranger type state (idle, set_str, send_str,endstring); signal cur_state: state; --signal str :string :=" "&cr; signal str :string :=" "&cr; signal counter :integer; constant letters_max : integer := 47; begin pro:process(clock,reset) variable data_count : integer range 0 10 :=0; begin if (reset='1') cur_state <= i