타입 테스트

타입 테스트

항의 타입을 검사하는 내장 술어들을 설명해요.

출처: GNU Prolog Manual - Type testing

본문

var/1, nonvar/1, atom/1, integer/1, float/1, number/1, atomic/1, compound/1, callable/1, ground/1, is_list/1, list/1, partial_list/1, list_or_partial_list/1

Templates

var(?term)
nonvar(?term)
atom(?term)
integer(?term)
float(?term)
number(?term)
atomic(?term)
compound(?term)
callable(?term)
ground(?term)
is_list(?term)
list(?term)
partial_list(?term)
list_or_partial_list(?term)

Description

  • var(Term) - Term이 현재 인스턴스화되지 않았으면(즉 아무것에도 바인딩되지 않았으면, 아마도 다른 인스턴스화되지 않은 변수에는 바인딩될 수 있음) 성공.
  • nonvar(Term) - Term이 현재 인스턴스화되어 있으면 성공(var/1의 반대).
  • atom(Term) - Term이 현재 원자에 인스턴스화되어 있으면 성공.
  • integer(Term) - Term이 현재 정수에 인스턴스화되어 있으면 성공.
  • float(Term) - Term이 현재 부동소수점 수에 인스턴스화되어 있으면 성공.
  • number(Term) - Term이 현재 정수 또는 부동소수점 수에 인스턴스화되어 있으면 성공.
  • atomic(Term) - Term이 현재 원자, 정수 또는 부동소수점 수에 인스턴스화되어 있으면 성공.
  • compound(Term) - Term이 현재 복합 항에 인스턴스화되어 있으면, 즉 아리티 > 0인 항(리스트 또는 구조체)이면 성공.
  • callable(Term) - Term이 현재 callable 항에, 즉 원자 또는 복합 항에 인스턴스화되어 있으면 성공.
  • ground(Term) - Term이 접지된(ground) 항이면 성공.
  • list(Term) - Term이 현재 리스트에, 즉 원자 [](빈 리스트)이거나 주 functor가 '.'/2이고 두 번째 인자(꼬리)가 리스트인 항이면 성공.
  • is_list(Term) - list(Term)처럼 동작(호환 목적).
  • partial_list(Term) - Term이 현재 부분 리스트에, 즉 변수이거나 주 functor가 '.'/2이고 두 번째 인자(꼬리)가 부분 리스트인 항이면 성공.
  • list_or_partial_list(Term) - Term이 현재 리스트 또는 부분 리스트에 인스턴스화되어 있으면 성공.

Errors: 없음.

Portability: var/1, nonvar/1, atom/1, integer/1, float/1, number/1, atomic/1, compound/1, callable/1, ground/1은 ISO 술어. list/1, partial_list/1, list_or_partial_list/1은 GNU Prolog 술어.

더 알아보기