Когда я делаю (/ 7 2)
, что я должен сделать для получения результата 3
? Если я делаю (/7 2.0), я добираюсь 3.5
, который является как ожидалось.
Используйте функцию
. В SBCL:
* (floor (/ 7 2))
3
1/2
возвращаются два значения, целочисленная часть и дробная часть.
Вы можете использовать функцию
:
(floor 7 2)
3
1
Обратите внимание, что он возвращает несколько значений, и вам нужен только первый. С этаж
Возвращает несколько значений, которые можно сделать с помощью Multi-Value-Bind
следующим образом:
(multiple-value-bind (q r) (floor 7 2) q)
=> 3
Редактировать: Как Rainer Notes в его комментарии, вы можете просто пройти Результат этажа
как аргумент, если все, что вам нужно, является частным.
[1]> (floor 7 2)
3 ;
1
[2]> (+ (floor 7 2) 5)
8
[3]>
Я покидаю ссылку на множественного значения-связывания
в ответе, поскольку это важная функция для знакома.
Если объект product
только что создан, его нельзя обновить ()
, поскольку в базе данных нет строки с исходными значениями объекта. Сначала необходимо сохранить ()
продукт
, а затем очистить ()
средство управления правами, после чего возможно обновить ()
.
Я только что нашел эти ресурсы:
// The DebuggerDisplayAttribute can be a sweet shortcut to avoid expanding
// the object to get to the value of a given property when debugging.
[DebuggerDisplay("ProductName = {ProductName},ProductSKU= {ProductSKU}")]
public class Product
{
public string ProductName { get; set; }
public string ProductSKU { get; set; }
}
// This attribute is great to skip through methods or properties
// that only have getters and setters defined.
[DebuggerStepThrough()]
public virtual int AddressId
{
get { return _AddressId;}
set
{
_AddressId = value;
OnPropertyChanged("AddressId");
}
}
// The method below is marked with the ObsoleteAttribute.
// Any code that attempts to call this method will get a warning.
[Obsolete("Do not call this method.")]
private static void SomeDeprecatedMethod() { }
// similar to using a combination of the DebuggerHidden attribute, which hides
// the code from the debugger, and the DebuggerStepThrough attribute, which tells
// the debugger to step through, rather than into, the code it is applied to.
[DebuggerNonUserCode()]
private static void SomeInternalCode() { }
-121--3007017- См. ПОЛ, ПОТОЛОК и УСЕЧЕНИЕ в ANSI Common Lisp.
Примеры (см. положительные и отрицательные числа):
CL-USER 218 > (floor -5 2)
-3
1
CL-USER 219 > (ceiling -5 2)
-2
-1
CL-USER 220 > (truncate -5 2)
-2
-1
CL-USER 221 > (floor 5 2)
2
1
CL-USER 222 > (ceiling 5 2)
3
-1
CL-USER 223 > (truncate 5 2)
2
1
Обычно используется для деления на целое число TRUNCATE.