Skip to content

Instantly share code, notes, and snippets.

@honki12345
Created September 25, 2025 16:12
Show Gist options
  • Select an option

  • Save honki12345/a0fc6e45a48c47617316d56519ff2cf9 to your computer and use it in GitHub Desktop.

Select an option

Save honki12345/a0fc6e45a48c47617316d56519ff2cf9 to your computer and use it in GitHub Desktop.

Revisions

  1. honki12345 created this gist Sep 25, 2025.
    8 changes: 8 additions & 0 deletions ex1.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    // Q. 리스트가 빈 리스트([])인지, 또는 첫 번째 요소가 빈 리스트인지([[], ['a','b']]와 같은)를 확인하는 표현식을 작성하세요.
    hasOnlyOneElement t = null t || null (head t)

    // Q. 다른 리스트 안에 주어진 두 리스트를 연결하는 표현식을 작성하세요. 예를 들어, ["abc","de"]에 대해 "abcde"를 반환해야 합니다.
    concatTwoElement t = head t ++ head (tail t)

    // Q. Q. 리스트가 단 하나의 요소만 가지고 있는지 확인하는 표현식을 작성하세요. ['a']에 대해서는 True를, []나 ['a','b']에 대해서는 False를 반환해야 합니다.
    hasOneElement t = not (null t) && null (tail t)