append - Appending lists in SML -


i'm trying add int list list int list list using append function, can't work way want.

say want append [[1,2,3,4,5]] [6,7] [[1,2,3,4,5,6,7]].

here's attempt: [1,2,3,4,5]::[]@[6,7]::[], gives me list want append list of own instead of 2 lists combined one, this: [[1,2,3,4,5],[6,7]].

how can re-write operation make return [[1,2,3,4,5,6,7]]?

your question unspecific. dealing nested lists. want append second list every inner list of nested list, or first one? example doesn't tell.

for former:

fun appendall xss ys = list.map (fn xs => xs @ ys) xss 

for latter:

fun appendhd [] ys = raise empty   | appendhd (xs::xss) ys = (xs @ ys)::xss 

however, both of these should needed, , somehow feel trying solve wrong problem if end there.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -