VBA, 512 489 479 byte
Sub f(A,B):Debug.?">>>>>->>>>->--<<<"&Replace(Replace(Replace(A,"<","<<<[+]-<<"),">",">>>>>>>[+]-<<"),".",">>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>>+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]-<<")&">>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>"&Replace(Replace(Replace(B,"<","<<<<<"),">",">>>>>"),",","[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<"):End Sub
Spiegazione
Il codice VBA modifica il codice brainfuck in un modo, che l'output dello snippet A verrà memorizzato in un elenco e l'input dello snippet B verrà letto da tale elenco.
Inizializza prima alcune variabili
>>>>>->>>>->--<<<
Poi si legge frammento di A e sostituisce ogni <
da <<<[+]-<<
ogni >
da >>>>>>>[+]-<<
ed ogni .
dalla routine di memorizzazione
>>>>>>>[+]-<<"),".",">>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<
successivamente elimina la memoria dello snippet A e apporta modifiche all'elenco memorizzato, in modo che possa essere letto come input per lo snippet B:
>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<
Quindi verrà letto lo snippet B, ciascuno <
verrà sostituito da <<<<<
, ogni >
verrà sostituito da >>>>>
e ogni ,
verrà sostituito dalla routine di lettura dell'elenco:
[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<
Codice sorgente di Brainfuck
Questa è la mia fonte per le porzioni di codice del cervello. Lo spiegherò in dettaglio più avanti.
[
Tape: tempMem data out/in dataAnchors outAnchors (all repeating)
dataAnchors of Snippet A: -1 = memory has been used, -2 = active memory cell for copying to out/in
dataAnchors of Snippet B: -1 = active memory cell for copying from out/in
outAnchors of Snippet A: -1 = start of list, -2 = next output position
outAnchors of Snippet B: -1 = character has been read (or start of input)
]
### Init
>> two blank data cells (for non wrapping pointer)
>>>- set start of input
>> >>- set first "used" flag
>-- set end of input
<<< return to first usable data cell
### A move right routine
>>>>> move to the next data cell
>>[+]- clear and set "used" flag
<< return to data cell
### A move left routine
<<<[+]- clear and set "used" flag of previous data cell
<< go to data cell
### A print routine
>>- set flag
<<[ while value greater 0
- decrement value
<+ increment tempMem
>>>>+[-<<<<<+] find start of input
+[-->>>>>++]-- find end of input
<<+ increment input
>>+[-<<<<<+]- find start of input
<++[-->>>>>++]--find flag
<< go to active data cell
]
<[->+<] move stored value back to data
>>>>+[-<<<<<+] find start of input
+[-->>>>>++] find end of input
>>>>>- set new end of input
[-<<<<<+]- return to start of input
<++[-->>>>>++]- return to and delete data flag
<< go to data cell
### After snippet A: Delete memory of A and configure out/in list
>>[>>>>>]<<<<< go to last used data
[+<<[-]<<<] delete each data
>++[-->>>>>++] find and delete end of input flag
+[-<<<<<+]- go to start of input
>> go to first data cell
### B move right routine
>>>>> go to next data cell
### B move left routine
<<<<< go to previous data cell
### B reading routine
[-] set cell = 0
>>- set flag
>[>>>>>]+[-<<<<<+]- find start of input
>>>[ if value greater 0
- decrement value
<<<[<<<<<]>>>> go to initial start of input (combined with next)
+[->>>>>+]- find mem cell flag
<<+ increment mem cell
>>>[>>>>>]+[-<<<<<+]->>> return to input cell
]
>>- set new start of input
[<<<<<]>>>> go to initial start of input (combined with next)
+[->>>>>+] find and delete mem cell flag
<< go to mem cell
Uscita per test case 1: f ",[..,]",",[...,]"
>>>>>->>>>->--<<<,[>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<,]>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<[...[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<]
Provalo online!
Uscita per test case 2: f ">,[>,]<[.<]",",[...,]"
>>>>>->>>>->--<<<>>>>>>>[+]-<<,[>>>>>>>[+]-<<,]<<<[+]-<<[>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<<<<[+]-<<]>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<[...[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<]
Provalo online!
Uscita per test case 3: f ",.",",."
>>>>>->>>>->--<<<,>>->+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]--<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>+<<>>[>>>>>]<<<<<[+<<[-]<<<]>++[-->>>>>++]+[-<<<<<+]->>>>>-<<<[-]>>->[>>>>>]+[-<<<<<+]->>>[-<<<[<<<<<]>>>>+[->>>>>+]-<<+>>>[>>>>>]+[-<<<<<+]->>>]>>-[<<<<<]>>>>+[->>>>>+]<<.
Provalo online!
Caso di test complesso:
frammento A: costruisci triangolo alfabetico >+++++[<+++++>-]<+[>>[>[.>]]>++++++++++.--[<++++++++>-]<[+.<]<-]>>,>[.>]++++++++++.[<[.<]>,>[.>]<]
Provalo online!
Snippet B: ordina l'ingresso in ordine crescente >>,[>>,]<<[[-<+<]>[>[>>]<[.[-]<[[>>+<<-]<]>>]>]<<]
Provalo online!
Risultato:
>>>>>->>>>->--<<<>>>>>>>[+]-<<+++++[<<<[+]-<<+++++>>>>>>>[+]-<<-]<<<[+]-<<+[>>>>>>>[+]-<<>>>>>>>[+]-<<[>>>>>>>[+]-<<[>>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>>+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]-<<>>>>>>>[+]-<<]]>>>>>>>[+]-<<++++++++++>>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>>>>+[-<<<<<+]+[-->>>>>++]>>>>>-[-<<<<<+]-<++[-->>>>>++]-<<--[<<<[+]-<<++++++++>>>>>>>[+]-<<-]<<<[+]-<<[+>>-<<[-<+>>>>+[-<<<<<+]+[-->>>>>++]--<<+>>+[-<<<<<+]-<++[-->>>>>++]--<<]<[->+<]>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>>>>>>>>]<<<<<[.[-]<<<<<[[>>>>>>>>>>+<<<<<<<<<<-]<<<<<]>>>>>>>>>>]>>>>>]<<<<<<<<<<]
Provalo online!
Shortest code in each language win
eShortest Brainfuck solution will be accepted
sono due diversi criteri vincenti.