How would I splice and add these two char arrays?

时间:2015-05-12 22:29:17

标签: java arrays

I have this array.

Declare @TableName as Varchar(255)
Set @TableName = '<MyTableName>'

Declare @SQL as Varchar(max)
Select @SQL = Coalesce(@SQL + '
', '') + 
CASE 
WHEN Row_Number() Over (Order by Database_ID) = 1 
THEN '' 
ELSE 
'UNION ALL ' 
END +
'SELECT 
  ''' + d.Name + '''    as DatabaseName
, s.Name                as SchemaName 
, o.Name                as TableName 
FROM ' + d.Name +'.Sys.Objects o 
INNER JOIN ' + d.Name + '.Sys.Schemas s
ON o.Schema_ID = s.Schema_ID
WHERE o.Name like ''' + @TableName + ''''
FROM sys.databases d
where d.Name not like 'ReportServer%'
and d.Name not like 'SSISPackageRegistry'

Print @SQL 
EXEC(@SQL)

I also have this array, for which the values are inputted by the user running the program.

char [] cornStrand = {'G','G','A','G','T','T','C','C','C','A'};

The second block of code essentially inputs the values that the user entered into the bacteria strand array.

Now comes the tricky part. I need to "splice" and combine both arrays. By this I mean:

If the first character of

char [] bacteriaStrand = new char [5];

String strBases = scan.nextLine();

    for (int s=0; s <bacteriaStrand.length; s++)
    {
        char c = strBases.charAt(s);
        bacteriaStrand[s]= c ;
    }

is A, then I have to insert

       char [] bacteriaStrand

After the first G in

  char [] bacteriaStrand

Now, after I splice this, I have to put what I spliced into a new array, called

char [] cornStrand

This is where I am becoming confused. If anyone can help, please do so! I would gladly appreciate it!

2 个答案:

答案 0 :(得分:0)

Maybe do something like this:

In [41]: import difflib

In [42]: d=difflib.Differ()


In [46]: a
Out[46]: ['a', 'b', 'c', 'd', 'e', 'f']

In [47]: b=['c','d','g']

In [48]: diff=d.compare(a,b)

In [49]: "".join(diff)
Out[49]: '- a- b  c  d+ g- e- f'

答案 1 :(得分:0)

If that is the only rule, it seems pretty simple to do.

$("[data-widget='collapse']").click(function() {
    //Find the box parent        
    var box = $(this).parents(".box").first();
    //Find the body and the footer
    var bf = box.find(".box-body, .box-footer");
    if (!box.hasClass("collapsed-box")) {
        box.addClass("collapsed-box");
        //Convert minus into plus
        $(this).children(".fa-minus").removeClass("fa-minus").addClass("fa-plus");
        bf.slideUp();
    } else {
        box.removeClass("collapsed-box");
        //Convert plus into minus
        $(this).children(".fa-plus").removeClass("fa-plus").addClass("fa-minus");
        bf.slideDown();
    }
});
相关问题