Ask Your Question
0

From two arrays to one arrays

asked 2017-02-17 16:47:06 +0100

Fede gravatar image

Hello! if I would like to obtain from two array: A = [a b c] B = [d e f] the following array C = [a b c d e f] there is a istruction to unite the arrays A and B?

Thank you in advance

Good life!

Fede

edit retag flag offensive close merge delete

Comments

I didn't tell you that I use StarBasic

Fede gravatar imageFede ( 2017-02-18 09:14:51 +0100 )edit

3 answers

Sort by » oldest newest most voted
0

answered 2017-02-17 17:28:07 +0100

Mike Kaganski gravatar image

updated 2017-02-18 09:46:07 +0100

https://help.libreoffice.org/Calc/Ope...

See tilde (~) operator. E.g.: =SUM(A1:A3~C4:C6)

Cannot be used in Data->Validity.

EDIT: Since you need a BASIC function, you may use this:

Function UnionArrays (Arr1, Arr2)
' Expects two 1-dimensional arrays
    Dim result
    result = Arr1
    ReDim Preserve result(UBound(Arr1)+UBound(Arr2)-LBound(Arr2)+1)
    Dim i As Integer
    i = UBound(Arr1)+1
    Dim n As Integer
    For n=LBound(Arr2) To UBound(Arr2)
        result(i) = Arr2(n)
        i = i+1
    Next n
    UnionArrays = result
End Function
edit flag offensive delete link more

Comments

I'm sorry, I didn't tell you that I use Starbasic

Fede gravatar imageFede ( 2017-02-18 09:12:01 +0100 )edit

Thank You Mike :D, Good Life

Fede gravatar imageFede ( 2017-02-18 09:46:02 +0100 )edit
0

answered 2017-02-18 17:51:08 +0100

pierre-yves samyn gravatar image

Hi

a = array("a","b","c")
b = array("d","e","f")

c = split(join(a, ",") & "," & join(b, ","), ",")

Regards

edit flag offensive delete link more

Comments

1

works only with strings inside array, and maybe partielly with integers or floats… python works with any objects inside lists

karolus gravatar imagekarolus ( 2017-02-18 20:42:25 +0100 )edit
0

answered 2017-02-17 17:34:27 +0100

karolus gravatar image

Hallo

It's easy as pie!

ipython-notebook-screen

edit flag offensive delete link more

Comments

Now that I'm thinking about it, OP does make 3 arrays (or lists, as Python, pictured above, calls them) which is using same syntax some languages use, and I don't remember seeing arrays made that way in Calc. I could be wrong, though. Python does make many things much easier than any other language AFAIK.

rautamiekka gravatar imagerautamiekka ( 2017-02-17 18:32:26 +0100 )edit

I didn't tell you that I use StarBasic sorry

Fede gravatar imageFede ( 2017-02-18 09:13:40 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-02-17 16:47:06 +0100

Seen: 38 times

Last updated: Feb 18