-
Notifications
You must be signed in to change notification settings - Fork 0
/
lists_utils3.c
60 lines (55 loc) · 1.69 KB
/
lists_utils3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lists_utils3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fulloa-s <fulloa-s@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/18 15:05:45 by gneri #+# #+# */
/* Updated: 2021/05/20 08:41:08 by fulloa-s ### ########.fr */
/* */
/* ************************************************************************** */
#include "checker.h"
void ft_cmds_list(t_cmd **node, t_cmd *cmd_b, t_cmd *cmd_a)
{
t_cmd *newcmd;
while (cmd_b)
{
if (!*node)
(*node) = ft_newcmd(cmd_b->cmd);
else
{
newcmd = ft_newcmd(cmd_b->cmd);
ft_lstadd_backcmd(&(*node), newcmd);
}
cmd_b = cmd_b->next;
}
while (cmd_a)
{
if (!*node)
(*node) = ft_newcmd(cmd_a->cmd);
else
{
newcmd = ft_newcmd(cmd_a->cmd);
ft_lstadd_backcmd(&(*node), newcmd);
}
cmd_a = cmd_a->next;
}
}
void ft_moves_list(t_cmd **node, t_cmd *cmd_b, t_cmd *cmd_a)
{
t_cmd *newcmd;
if (!*node)
{
(*node) = ft_newcmd(cmd_b->cmd);
newcmd = ft_newcmd(cmd_a->cmd);
ft_lstadd_backcmd(&(*node), newcmd);
}
else
{
newcmd = ft_newcmd(cmd_b->cmd);
ft_lstadd_backcmd(node, newcmd);
newcmd = ft_newcmd(cmd_a->cmd);
ft_lstadd_backcmd(&(*node), newcmd);
}
}