Hi, I was wondering if there was some way to emulate R.E.Boss's elegant code to generate all the substrings of consecutive elements of a vector :
<@(<\.)\'abcde' ┌───┬──────┬──────────┬───────────────┬─────────────────────┐ │┌─┐│┌──┬─┐│┌───┬──┬─┐│┌────┬───┬──┬─┐│┌─────┬────┬───┬──┬─┐│ ││a│││ab│b│││abc│bc│c│││abcd│bcd│cd│d│││abcde│bcde│cde│de│e││ │└─┘│└──┴─┘│└───┴──┴─┘│└────┴───┴──┴─┘│└─────┴────┴───┴──┴─┘│ └───┴──────┴──────────┴───────────────┴─────────────────────┘ ;<@(<\.)\'abcde' ┌─┬──┬─┬───┬──┬─┬────┬───┬──┬─┬─────┬────┬───┬──┬─┐ │a│ab│b│abc│bc│c│abcd│bcd│cd│d│abcde│bcde│cde│de│e│ └─┴──┴─┴───┴──┴─┴────┴───┴──┴─┴─────┴────┴───┴──┴─┘ Using infix with all the substring lengths almost gets us there but there are a lot of empty cells : , (>:i.5) <\'abcde' ┌─┬─┬─┬─┬─┬──┬──┬──┬──┬┬───┬───┬───┬┬┬────┬────┬┬┬┬─────┬┬┬┬┐ │a│b│c│d│e│ab│bc│cd│de││abc│bcd│cde│││abcd│bcde││││abcde│││││ └─┴─┴─┴─┴─┴──┴──┴──┴──┴┴───┴───┴───┴┴┴────┴────┴┴┴┴─────┴┴┴┴┘ Is there an elegant way of eliminating the empty cells ? Thanks, Jimmy PS Adding oblique and transpose gives the same order as R.E.Boss's expression : ; <@, /. |: (>:i.5) <\'abcde' ┌─┬──┬─┬───┬──┬─┬────┬───┬──┬─┬─────┬────┬───┬──┬─┬┬┬┬┬┬┬┬┬┬┐ │a│ab│b│abc│bc│c│abcd│bcd│cd│d│abcde│bcde│cde│de│e│││││││││││ └─┴──┴─┴───┴──┴─┴────┴───┴──┴─┴─────┴────┴───┴──┴─┴┴┴┴┴┴┴┴┴┴┘ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm