Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna and Leaky Nun for saving 10 bytes!
###Code
Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
Try it online! or Verify all test cases!
###Explanation:
Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna and Leaky Nun for saving 10 bytes!
###Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
Try it online! or Verify all test cases!
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna and Leaky Nun for saving 10 bytes!
Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
Try it online! or Verify all test cases!
Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna and Leaky Nun for saving 10 bytes!
###Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
Try it online! or Verify all test cases!
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna for saving 10 bytes!
###Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna and Leaky Nun for saving 10 bytes!
###Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
Try it online! or Verify all test cases!
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), 43(削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna for saving 10 bytes!
###Code
a([]).
a([2|T]):-a(T).
a([X|T]):-a(X=2;a(X)),a(T).
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the headlist is equalnot toempty 2(covered by the previous line), onlywe need to check
% ifwhether the tailHead is truthy.
a([2 |equal Tail])to :-2 a(Tail).
%or Ifwhether the head is not equaltruthy.
% toAfter 2that, we only need to check if the headremaining andlist tailis seperatelytruthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).
Prolog (SWI), 43 bytes
I smell... recursion.
###Code
a([]).
a([2|T]):-a(T).
a([X|T]):-a(X),a(T).
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the head is equal to 2, only check if the tail is truthy.
a([2 | Tail]) :- a(Tail).
% If the head is not equal to 2, check the head and tail seperately.
a([Head | Tail]) :- a(Head), a(Tail).
Prolog (SWI), (削除) 43 (削除ここまで) 33 bytes
I smell... recursion.
Thanks to Emigna for saving 10 bytes!
###Code
a([]).
a([X|T]):-(X=2;a(X)),a(T).
###Explanation:
For non-Prolog users, a list is formatted in the following way: [Head | Tail].
The Head is the first element of the list, and tail is the remaining list. Test it here!. An important case here is that the tail of a list with 1 element is equal to []. You can test that here.
% State that an empty array is truthy.
a([]).
% If the list is not empty (covered by the previous line), we need to check
% whether the Head is equal to 2 or whether the head is truthy.
% After that, we only need to check if the remaining list is truthy.
a([Head | Tail]) :- (Head = 2; a(Head)), a(Tail).