Skip to content

Commit 142ef55

Browse files
committed
finished translating tasks
1 parent e438278 commit 142ef55

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

1-js/06-advanced-functions/01-recursion/04-output-single-linked-list/solution.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Loop-based solution
1+
# Soluție bazată pe loop
22

3-
The loop-based variant of the solution:
3+
Varianta soluției bazată pe loop:
44

55
```js run
66
let list = {
@@ -30,7 +30,7 @@ function printList(list) {
3030
printList(list);
3131
```
3232

33-
Please note that we use a temporary variable `tmp` to walk over the list. Technically, we could use a function parameter `list` instead:
33+
Vă rugăm să rețineți că folosim o variabilă temporară `tmp` pentru a parcurge lista. Din punct de vedere tehnic, am putea folosi în schimb un parametru de funcție `list`:
3434

3535
```js
3636
function printList(list) {
@@ -43,15 +43,15 @@ function printList(list) {
4343
}
4444
```
4545

46-
...But that would be unwise. In the future we may need to extend a function, do something else with the list. If we change `list`, then we lose such ability.
46+
...Dar asta ar fi neînțelept. În viitor s-ar putea să avem nevoie să extindem o funcție, să facem altceva cu lista. Dacă schimbăm `list`, atunci pierdem o astfel de abilitate.
4747

48-
Talking about good variable names, `list` here is the list itself. The first element of it. And it should remain like that. That's clear and reliable.
48+
Vorbind despre nume de variabile bune, `list` aici este lista însăși. Primul element al acesteia. Și ar trebui să rămână așa. Este clar și de încredere.
4949

50-
From the other side, the role of `tmp` is exclusively a list traversal, like `i` in the `for` loop.
50+
De cealaltă parte, rolul lui `tmp` este exclusiv o traversare a listei, ca și `i` în bucla `for`.
5151

52-
# Recursive solution
52+
# Soluție recursivă
5353

54-
The recursive variant of `printList(list)` follows a simple logic: to output a list we should output the current element `list`, then do the same for `list.next`:
54+
Varianta recursivă a `printList(list)` urmează o logică simplă: pentru a scoate o listă trebuie să scoatem elementul curent `list`, apoi să facem același lucru pentru `list.next`:
5555

5656
```js run
5757
let list = {
@@ -70,19 +70,19 @@ let list = {
7070

7171
function printList(list) {
7272

73-
alert(list.value); // output the current item
73+
alert(list.value); // afișează elementul curent
7474

7575
if (list.next) {
76-
printList(list.next); // do the same for the rest of the list
76+
printList(list.next); // procedează la fel pentru restul listei
7777
}
7878

7979
}
8080

8181
printList(list);
8282
```
8383

84-
Now what's better?
84+
Acum ce este mai bine?
8585

86-
Technically, the loop is more effective. These two variants do the same, but the loop does not spend resources for nested function calls.
86+
Din punct de vedere tehnic, un loop este mai eficient. Aceste două variante fac același lucru, dar loop-ul nu consumă resurse pentru apeluri de funcții nested.
8787

88-
From the other side, the recursive variant is shorter and sometimes easier to understand.
88+
De partea cealaltă, varianta recursivă este mai scurtă și uneori mai ușor de înțeles.

1-js/06-advanced-functions/01-recursion/04-output-single-linked-list/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Output a single-linked list
5+
# Scoate un singur linked list
66

7-
Let's say we have a single-linked list (as described in the chapter <info:recursion>):
7+
Să presupunem că avem un singur linked list (așa cum este descris în capitolul <info:recursion>):
88

99
```js
1010
let list = {
@@ -22,8 +22,8 @@ let list = {
2222
};
2323
```
2424

25-
Write a function `printList(list)` that outputs list items one-by-one.
25+
Scrieți o funcție `printList(list)` care scoate elementele din listă unul câte unul.
2626

27-
Make two variants of the solution: using a loop and using recursion.
27+
Realizați două variante ale soluției: folosind un loop și folosind recursivitatea.
2828

29-
What's better: with recursion or without it?
29+
Ce este mai bine: cu recursivitate sau fără ea?

1-js/06-advanced-functions/01-recursion/05-output-single-linked-list-reverse/solution.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Using a recursion
1+
# Folosind o recursiune
22

3-
The recursive logic is a little bit tricky here.
3+
Logica recursivă este un pic mai înșelătore aici.
44

5-
We need to first output the rest of the list and *then* output the current one:
5+
Trebuie să scoatem mai întâi restul listei și *apoi* să o scoatem pe cea curentă:
66

77
```js run
88
let list = {
@@ -31,13 +31,13 @@ function printReverseList(list) {
3131
printReverseList(list);
3232
```
3333

34-
# Using a loop
34+
# Utilizarea unui loop
3535

36-
The loop variant is also a little bit more complicated than the direct output.
36+
Varianta loop este de asemenea un pic mai complicată decât scoaterea directă.
3737

38-
There is no way to get the last value in our `list`. We also can't "go back".
38+
Nu există nicio modalitate de a obține ultima valoare din `list`. De asemenea nu putem "merge înapoi".
3939

40-
So what we can do is to first go through the items in the direct order and remember them in an array, and then output what we remembered in the reverse order:
40+
Așadar, ceea ce putem face este să parcurgem mai întâi elementele în ordine directă și să le reținem într-un array, iar apoi să scoatem ceea ce am reținut în ordine inversă:
4141

4242
```js run
4343
let list = {
@@ -71,4 +71,4 @@ function printReverseList(list) {
7171
printReverseList(list);
7272
```
7373

74-
Please note that the recursive solution actually does exactly the same: it follows the list, remembers the items in the chain of nested calls (in the execution context stack), and then outputs them.
74+
Vă rugăm să notați că soluția recursivă face de fapt exact la fel: urmărește lista, își amintește elementele din lanțul de apeluri nested (în execution context stack) și apoi le scoate.

1-js/06-advanced-functions/01-recursion/05-output-single-linked-list-reverse/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ importance: 5
22

33
---
44

5-
# Output a single-linked list in the reverse order
5+
# Scoate un singur linked list în ordine inversă
66

7-
Output a single-linked list from the previous task <info:task/output-single-linked-list> in the reverse order.
7+
Scoate un singur linked list din sarcina anterioară <info:task/output-single-linked-list> în ordine inversă.
88

9-
Make two solutions: using a loop and using a recursion.
9+
Realizați două soluții: folosind un loop și folosind o recursivitate.

0 commit comments

Comments
 (0)