Post Reply 
mat2list command
02-18-2014, 12:37 AM (This post was last modified: 02-18-2014 01:04 AM by massimo.)
Post: #2
RE: mat2list command
Assign it to a "L" variable:

L3:=mat2list([[1,2],[3,4]])

Not very elegant, indeed.

Why not use some recursion in a CAS function?

lc(a):=PIECEWISE((length(a)) = 0,{},(length(a))>0,concat({head(a)},lc(tail(a))))

lc([a b c]) returns {a b c}

I like functional languages! BTW this is a classic example of tail recursion. Many functional languages translate it to a loop. It will be nice to know which is the CAS behavior.

Massimo
from 34c to prime
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
mat2list command - Thomas Ritschel - 02-17-2014, 09:11 PM
RE: mat2list command - massimo - 02-18-2014 12:37 AM
RE: mat2list command - parisse - 02-18-2014, 08:01 AM
RE: mat2list command - Thomas Ritschel - 02-18-2014, 06:57 PM
RE: mat2list command - parisse - 02-19-2014, 07:38 AM



User(s) browsing this thread: 1 Guest(s)